summaryrefslogtreecommitdiff
path: root/usb_fmt.cpp (plain)
blob: 45063a1226ea02c64e133454665a511102ae2b4b
1#ifndef __USB_FMT_C__
2#define __USB_FMT_C__
3
4#include <utils/Log.h>
5#include "usb_fmt.h"
6#include "DebugUtils.h"
7
8struct usb_fmt_s{
9 uint32_t p;
10 struct v4l2_frmsize_discrete d;
11}usb_fmt_t;
12
13struct usb_device_s {
14 uint16_t idVendor;
15 uint16_t idProduct;
16 uint32_t num;
17 struct usb_fmt_s *uf;
18}usb_device_t;
19
20
21static struct usb_fmt_s id_046d_082b[] = {
22 {
23 .p = V4L2_PIX_FMT_MJPEG,
24 {
25 .width = 640,
26 .height = 480,
27 }
28 },{
29 .p = V4L2_PIX_FMT_MJPEG,
30 {
31 .width = 320,
32 .height = 240,
33 }
34 },
35};
36
37static struct usb_device_s aml_usb_pixelfmt[] = {
38 {
39 .idVendor = 0x046d,
40 .idProduct= 0x082b,
41 .num = ARRAY_SIZE(id_046d_082b),
42 .uf = id_046d_082b,
43 },
44};
45
46extern "C" uint32_t query_aml_usb_pixelfmt(uint16_t idVendor, uint16_t idProduct,
47 uint16_t w, uint16_t h)
48{
49 int i;
50 struct usb_fmt_s *uf;
51 int num = 0;
52#if 0
53 CAMHAL_LOGIB("idVendor=%x, idProduct=%x, w=%d, h=%d\n",
54 idVendor,idProduct, w, h);
55#endif
56
57 for (i = 0; i<(int)ARRAY_SIZE(aml_usb_pixelfmt); i++){
58#if 0
59 CAMHAL_LOGIB("i=%d,idVendor=%x, idProduct=%x\n",
60 i, aml_usb_pixelfmt[i].idVendor,
61 aml_usb_pixelfmt[i].idProduct);
62#endif
63
64 if((aml_usb_pixelfmt[i].idVendor == idVendor) &&
65 (aml_usb_pixelfmt[i].idProduct == idProduct)){
66 num =aml_usb_pixelfmt[i].num;
67 uf = aml_usb_pixelfmt[i].uf;
68 break;
69 }
70 }
71
72 if ((0 == num) || (NULL == uf)){
73 return 0;
74 }
75
76 for (i = 0; i < num; i++){
77#if 0
78 CAMHAL_LOGIB("i=%d, w=%d, h=%d\n", i, uf[i].d.width, uf[i].d.height);
79#endif
80 if((w == uf[i].d.width) && (h == uf[i].d.height)){
81 return uf[i].p;
82 }
83 }
84 return 0;
85}
86#endif
87