I have attached a USB camera to our sabre board.
solved some minor USB problems the camera was correctly recognized from USB/GSPCA/ then to V4L2.
but it says that some header (quantization table and huffman ) are missing.
Looking at the driver (pac7302.c in /driver/media/video/gspca) we can see that it doesn't add such part of headers (i think they are necessary).
So ther is something to activate some where so a part of GSPCA or V4L add such missing header stuff?
Thanks
Omar
已解决! 转到解答。
Not sure if PAC7302 supports programmable Quantization table. Take W9967CF as an example, W9967CF supports programmable Quantization, so you can find its registers (CR40-CR5F) are able to updated with Quantization table.
For PAC7302, you may check with its vendor, if the table can be updated, then you update by writing its registers just like w9967CF. But according to PAC7302 driver, the tables seem unable to change.
//"drivers/media/video/gspca/pac7302.c"
789 /* JPEG header, continued */
790 static const unsigned char pac_jpeg_header2[] = {
791 0x03, /* Number of image components: 3 */
792 0x01, 0x21, 0x00, /* ID=1, Subsampling 1x1, Quantization table: 0 */
793 0x02, 0x11, 0x01, /* ID=2, Subsampling 2x1, Quantization table: 1 */
794 0x03, 0x11, 0x01, /* ID=3, Subsampling 2x1, Quantization table: 1 */
795
796 0xff, 0xda, /* SOS: Start Of Scan */
797 0x00, 0x0c, /* length = 12 bytes (including this length field) */
798 0x03, /* number of components: 3 */
799 0x01, 0x00, /* selector 1, table 0x00 */
800 0x02, 0x11, /* selector 2, table 0x11 */
801 0x03, 0x11, /* selector 3, table 0x11 */
802 0x00, 0x3f, /* Spectral selection: 0 .. 63 */
803 0x00 /* Successive approximation: 0 */
804 };
--//"drivers/media/video/gspca/w996Xcf.c"
144 /*--------------------------------------------------------------------------
145 Upload quantization tables for the JPEG compression.
146 This function is called by w9968cf_start_transfer().
147 Return 0 on success, a negative number otherwise.
148 --------------------------------------------------------------------------*/
149 static int w9968cf_upload_quantizationtables(struct sd *sd)
150 {
151 u16 a, b;
152 int ret = 0, i, j;
153
154 ret += reg_w(sd, 0x39, 0x0010); /* JPEG clock enable */
155
156 for (i = 0, j = 0; i < 32; i++, j += 2) {
157 a = Y_QUANTABLE[j] | ((unsigned)(Y_QUANTABLE[j+1]) << 8);
158 b = UV_QUANTABLE[j] | ((unsigned)(UV_QUANTABLE[j+1]) << 8);
159 ret += reg_w(sd, 0x40+i, a);
160 ret += reg_w(sd, 0x60+i, b);
161 }
162 ret += reg_w(sd, 0x39, 0x0012); /* JPEG encoder enable */
163
164 return ret;
165 }
ok, so I have to modify the pac7302.c file and add the jpeg header statically to avery frame took from the usb camera?
But of course the quantization table and huffman are not the same used by the camera to produce the jpeg image.... so i should have also a method to write those table to the camera , and says to it which quantization to use (usually there are 3 different quantizaiton table)....
So the header can be static but the info in it should be cooherent with the table used by the camera to produce the jpeg frame....
Not sure if PAC7302 supports programmable Quantization table. Take W9967CF as an example, W9967CF supports programmable Quantization, so you can find its registers (CR40-CR5F) are able to updated with Quantization table.
For PAC7302, you may check with its vendor, if the table can be updated, then you update by writing its registers just like w9967CF. But according to PAC7302 driver, the tables seem unable to change.
//"drivers/media/video/gspca/pac7302.c"
789 /* JPEG header, continued */
790 static const unsigned char pac_jpeg_header2[] = {
791 0x03, /* Number of image components: 3 */
792 0x01, 0x21, 0x00, /* ID=1, Subsampling 1x1, Quantization table: 0 */
793 0x02, 0x11, 0x01, /* ID=2, Subsampling 2x1, Quantization table: 1 */
794 0x03, 0x11, 0x01, /* ID=3, Subsampling 2x1, Quantization table: 1 */
795
796 0xff, 0xda, /* SOS: Start Of Scan */
797 0x00, 0x0c, /* length = 12 bytes (including this length field) */
798 0x03, /* number of components: 3 */
799 0x01, 0x00, /* selector 1, table 0x00 */
800 0x02, 0x11, /* selector 2, table 0x11 */
801 0x03, 0x11, /* selector 3, table 0x11 */
802 0x00, 0x3f, /* Spectral selection: 0 .. 63 */
803 0x00 /* Successive approximation: 0 */
804 };
--//"drivers/media/video/gspca/w996Xcf.c"
144 /*--------------------------------------------------------------------------
145 Upload quantization tables for the JPEG compression.
146 This function is called by w9968cf_start_transfer().
147 Return 0 on success, a negative number otherwise.
148 --------------------------------------------------------------------------*/
149 static int w9968cf_upload_quantizationtables(struct sd *sd)
150 {
151 u16 a, b;
152 int ret = 0, i, j;
153
154 ret += reg_w(sd, 0x39, 0x0010); /* JPEG clock enable */
155
156 for (i = 0, j = 0; i < 32; i++, j += 2) {
157 a = Y_QUANTABLE[j] | ((unsigned)(Y_QUANTABLE[j+1]) << 8);
158 b = UV_QUANTABLE[j] | ((unsigned)(UV_QUANTABLE[j+1]) << 8);
159 ret += reg_w(sd, 0x40+i, a);
160 ret += reg_w(sd, 0x60+i, b);
161 }
162 ret += reg_w(sd, 0x39, 0x0012); /* JPEG encoder enable */
163
164 return ret;
165 }