Commit aca0c9b9 authored by Mikhail Karpenko's avatar Mikhail Karpenko

Add multichannel support to jpeghead.c, fix formatting

parent e14c7478
...@@ -117,29 +117,6 @@ int init_ccam_dma_buf_ptr(struct platform_device *pdev) ...@@ -117,29 +117,6 @@ int init_ccam_dma_buf_ptr(struct platform_device *pdev)
return 0; return 0;
} }
/**
* @brief Converts file minor number to image compressor channel.
*
* This function assumes that the least significant nibble of minor contains image compressor channel number and
* next nibble contains device type. Channel numbers and device type are defined in #driver_numbers.h
* @param[in] minor file minor number
* @param[out] dev_type pointer to a variable which will hold device type or NULL if this value is not needed
* @return compressor channel number in the range [0..#IMAGE_CHN_NUM)
*/
static inline unsigned int minor_to_chn(unsigned int minor, unsigned int *dev_type)
{
if (dev_type != NULL) {
if ((minor & 0xf0) == CIRCBUF_MINOR || (minor & 0xf0) == HUFFMAN_MINOR || (minor & 0xf0) == JPEGHEAD_MINOR)
*dev_type = minor & 0xf0;
else
*dev_type = 0;
}
if ((minor & 0x0f) < IMAGE_CHN_NUM)
return minor & 0x0f;
else
return 0;
}
int circbuf_all_open(struct inode *inode, struct file *filp) int circbuf_all_open(struct inode *inode, struct file *filp)
{ {
int res; int res;
...@@ -747,6 +724,7 @@ static int circbuf_all_init(struct platform_device *pdev) ...@@ -747,6 +724,7 @@ static int circbuf_all_init(struct platform_device *pdev)
dev_err(dev, "couldn't get a major number %d.\n", CIRCBUF_MAJOR); dev_err(dev, "couldn't get a major number %d.\n", CIRCBUF_MAJOR);
return res; return res;
} }
dev_info(dev, "registered MAJOR: %d\n", CIRCBUF_MAJOR);
res = init_ccam_dma_buf_ptr(pdev); res = init_ccam_dma_buf_ptr(pdev);
if (res < 0) { if (res < 0) {
...@@ -757,9 +735,12 @@ static int circbuf_all_init(struct platform_device *pdev) ...@@ -757,9 +735,12 @@ static int circbuf_all_init(struct platform_device *pdev)
dev_dbg(dev, "initialize circbuf wait queue\n"); dev_dbg(dev, "initialize circbuf wait queue\n");
init_waitqueue_head(&circbuf_wait_queue); init_waitqueue_head(&circbuf_wait_queue);
dev_dbg(dev, "initialize Huffman tables with default data\n"); dev_dbg(dev, "initialize Huffman tables with default data\n");
jpeg_htable_init (); /// set default Huffman table, encode it for the FPGA
dev_info(dev, "registered MAJOR: %d\n", CIRCBUF_MAJOR); res = jpeghead_init(pdev);
if (res < 0) {
dev_err(dev, "unable to initialize jpeghead module\n");
return res;
}
res = image_acq_init(pdev); res = image_acq_init(pdev);
if (res < 0) { if (res < 0) {
dev_err(dev, "unable to initialize sensor_common module\n"); dev_err(dev, "unable to initialize sensor_common module\n");
......
This diff is collapsed.
...@@ -10,7 +10,7 @@ struct huffman_fpga_code_t { ...@@ -10,7 +10,7 @@ struct huffman_fpga_code_t {
unsigned short length; /// code length unsigned short length; /// code length
}; };
int qtables_create (struct interframe_params_t * params, unsigned char * buf); int qtables_create (struct interframe_params_t * params, unsigned char * buf);
int jpegheader_create(struct interframe_params_t * params, unsigned char * buf); int jpegheader_create(struct interframe_params_t * params, unsigned char * buf, unsigned int chn);
int jpeghead_open (struct inode *inode, struct file *filp); // set filesize int jpeghead_open (struct inode *inode, struct file *filp); // set filesize
loff_t jpeghead_lseek (struct file * file, loff_t offset, int orig, struct interframe_params_t *fp); loff_t jpeghead_lseek (struct file * file, loff_t offset, int orig, struct interframe_params_t *fp);
ssize_t jpeghead_read (struct file * file, char * buf, size_t count, loff_t *off); ssize_t jpeghead_read (struct file * file, char * buf, size_t count, loff_t *off);
...@@ -35,10 +35,12 @@ struct huffman_pd { ...@@ -35,10 +35,12 @@ struct huffman_pd {
int minor;/// should be the first, same as in circbuf_pd int minor;/// should be the first, same as in circbuf_pd
}; };
int jpeg_htable_is_programmed(void); int jpeg_htable_is_programmed(unsigned int chn);
void jpeg_htable_init (void); void jpeg_htable_init(unsigned int chn);
int jpeg_htable_fpga_encode (void); int jpeg_htable_fpga_encode(unsigned int chn);
void jpeg_htable_fpga_pgm (unsigned int chn); void jpeg_htable_fpga_pgm(unsigned int chn);
int jpeg_prep_htable (struct huffman_encoded_t * htable, struct huffman_fpga_code_t * hcodes); int jpeg_prep_htable(struct huffman_encoded_t * htable, struct huffman_fpga_code_t * hcodes);
int jpeghead_init(struct platform_device *pdev);
#endif /* _JPEGHEAD */ #endif /* _JPEGHEAD */
...@@ -25,33 +25,33 @@ ...@@ -25,33 +25,33 @@
*/ */
//copied from cxi2c.c - TODO:remove unneeded //copied from cxi2c.c - TODO:remove unneeded
#include <linux/module.h> //#include <linux/module.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/slab.h> //#include <linux/slab.h>
#include <linux/errno.h> //#include <linux/errno.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/fs.h> //#include <linux/fs.h>
#include <linux/string.h> //#include <linux/string.h>
#include <linux/init.h> #include <linux/init.h>
//#include <linux/autoconf.h> //#include <linux/autoconf.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/time.h> #include <linux/time.h>
#include <linux/vmalloc.h> //#include <linux/vmalloc.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/of.h> //#include <linux/of.h>
#include <linux/of_device.h> //#include <linux/of_device.h>
//#include <asm/system.h> //#include <asm/system.h>
#include <asm/byteorder.h> // endians //#include <asm/byteorder.h> // endians
#include <asm/io.h> //#include <asm/io.h>
//#include <asm/arch/hwregs/intr_vect_defs.h> /// ETRAX interrupt registers //#include <asm/arch/hwregs/intr_vect_defs.h> /// ETRAX interrupt registers
#include <asm/irq.h> //#include <asm/irq.h>
#include <asm/delay.h> //#include <asm/delay.h>
#include <asm/uaccess.h> //#include <asm/uaccess.h>
#include <elphel/driver_numbers.h> #include <elphel/driver_numbers.h>
#include <elphel/c313a.h> #include <elphel/c313a.h>
//#include <asm/elphel/fpgaconfa.h> //#include <asm/elphel/fpgaconfa.h>
...@@ -775,11 +775,12 @@ int image_acq_stop(struct platform_device *pdev) ...@@ -775,11 +775,12 @@ int image_acq_stop(struct platform_device *pdev)
return 0; return 0;
} }
static const struct of_device_id elphel393_sensor_of_match[] = { //static const struct of_device_id elphel393_sensor_of_match[] = {
{ .compatible = "elphel,elphel393-sensor-1.00" }, // { .compatible = "elphel,elphel393-sensor-1.00" },
{ /* end of list */ } // { /* end of list */ }
}; //};
MODULE_DEVICE_TABLE(of, elphel393_sensor_of_match); //MODULE_DEVICE_TABLE(of, elphel393_sensor_of_match);
/*static struct platform_driver elphel393_sensor_common = { /*static struct platform_driver elphel393_sensor_common = {
.probe = image_acq_init, .probe = image_acq_init,
...@@ -792,6 +793,6 @@ MODULE_DEVICE_TABLE(of, elphel393_sensor_of_match); ...@@ -792,6 +793,6 @@ MODULE_DEVICE_TABLE(of, elphel393_sensor_of_match);
//module_platform_driver(elphel393_sensor_common); //module_platform_driver(elphel393_sensor_common);
MODULE_LICENSE("GPL"); //MODULE_LICENSE("GPL");
MODULE_AUTHOR("Andrey Filippov <andrey@elphel.com>."); //MODULE_AUTHOR("Andrey Filippov <andrey@elphel.com>.");
MODULE_DESCRIPTION(IMAGEACQ_DRIVER_NAME); //MODULE_DESCRIPTION(IMAGEACQ_DRIVER_NAME);
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#ifndef _X393_MACRO #ifndef _X393_MACRO
#define _X393_MACRO #define _X393_MACRO
#include <elphel/driver_numbers.h>
/** @brief Number of image channels */ /** @brief Number of image channels */
#define IMAGE_CHN_NUM 4 #define IMAGE_CHN_NUM 4
...@@ -39,4 +41,27 @@ ...@@ -39,4 +41,27 @@
#define X393_BUFFSUB(x, y) (((x) >= (y)) ? ((x)-(y)) : ((x) + (CCAM_DMA_SIZE -(y)))) #define X393_BUFFSUB(x, y) (((x) >= (y)) ? ((x)-(y)) : ((x) + (CCAM_DMA_SIZE -(y))))
#define X393_BUFFADD(x, y) ((((x) + (y)) <= CCAM_DMA_SIZE) ? ((x) + (y)) : ((x) - (CCAM_DMA_SIZE -(y)))) #define X393_BUFFADD(x, y) ((((x) + (y)) <= CCAM_DMA_SIZE) ? ((x) + (y)) : ((x) - (CCAM_DMA_SIZE -(y))))
/**
* @brief Converts file minor number to image compressor channel.
*
* This function assumes that the least significant nibble of minor number contains image compressor channel number and
* next nibble contains device type. Channel numbers and device type are defined in #driver_numbers.h
* @param[in] minor file minor number
* @param[out] dev_type pointer to a variable which will hold device type or NULL if this value is not needed
* @return compressor channel number in the range [0..#IMAGE_CHN_NUM)
*/
static inline unsigned int minor_to_chn(unsigned int minor, unsigned int *dev_type)
{
if (dev_type != NULL) {
if ((minor & 0xf0) == CIRCBUF_MINOR || (minor & 0xf0) == HUFFMAN_MINOR || (minor & 0xf0) == JPEGHEAD_MINOR)
*dev_type = minor & 0xf0;
else
*dev_type = 0;
}
if ((minor & 0x0f) < IMAGE_CHN_NUM)
return minor & 0x0f;
else
return 0;
}
#endif /* _X393_MACRO */ #endif /* _X393_MACRO */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment