|
发表于 2013-5-17 16:29:42
|
显示全部楼层
另外,它还定义了图像格式相关的常量和数据结构(如图像分辨率,色彩空间,调色板等),帧数据结构,摄像头操作方法集等。
Vimicro,Sonix,PixArt,Sunplus等文件夹中定义了各传感器相关的头文件。
decoder文件夹中包含了对各种图像格式进行编解码的源代码。
结论:要驱动一个摄像头,首先要知道它的DSP芯片和CMOS芯片型号。如果摄像头的Vendor ID,DSP芯片,image sensor不在其中,则要定义DSP和sensor芯片的相应头文件,并在gspca.h中添加相应的设备信息,还要把摄像头加入到gspca_core.c的摄像头设备列表中。
(2)与Logitech QuickCam Easy/Cool相近的摄像头信息列表
Camera Type
Product ID
Bridge DSP
Sensor
Comments(sensor in driver code)
QC IM
08a0
zc030x
HDCS2020
TAS5130C(08a0/a1/a3,08d9/da)
QC IM
08a6
zc030x
HV7131R
HV7131C (08a6/ad, 08d7)
NoteBook Deluxe
08a9
zc0302
HV7131B
HDCS2020 (08a2/a9/ae, 08d8)
QC Image
08a7
zc030x
PAS202
QC for Notebook
08ae
zc030x
PAS202
HDCS2020
QC Cool
08ac
zc030x
PAS202
HV7131B
Communicate STX
08ad
zc0302
TAS5130C
HV7131C
Communicate STX
08d7
vc0302/zc0302
TAS5130C
HV7131C
QC IM/Connect
08d9
zc030x
TAS5130C
QC Messenger
08da
zc030x
TAS5130C
NoteBook Deluxe
08d8
vc0302/zc0302
TAS5130C
QC Easy/Cool
08af
?(zc030x)
?
(HV7131C/HV7131B/TAS5130C/HDCS2020)
上面是Logitech摄像头产品中与Logitech QuickCam Easy/Cool相近的产品(从Product ID,摄像头英文名,产品价格等判断),摘自http://mxhaard.free.fr/spca5xx.html,其中最后一列的注释是gspca_core.c源文件中给相应型号摄像头定义的CMOS芯片型号,与网页上的列表并不完全一致,我们以驱动程序中定义的为准。
列出上面的表,主要是为了要推断出Logitech QuickCam Easy/Cool的DSP芯片型号和CMOS传感器型号。从上表可以发现,所有的摄像头都使用了zc030x(包括zc0302)作为DSP控制芯片,因此可以断定,Easy/Cool也使用了这一系列的DSP芯片,在驱动程序中用BRIDGE_ZC3XX表示。而CMOS芯片也无非是HV7131C/HV7131B/TAS5130C/HDCS2020中的一种,我们可以逐一试验。
(3)在gspca_core.c中添加Logitech QuickCam Easy/Cool相关信息
由于Logitech QuickCam Easy/Cool的Vendor、DSP型号、CMOS传感器型号在gspca.h中均有定义,也有相关的芯片头文件,因此,只需改动gspca_core.c,把Easy/Cool摄像头的信息加入到其中即可。
以下蓝色部分是添加的相关内容。
在gspca_core.c中有一个Camera型号列表,如下: enum {
UnknownCamera = 0, // 0
IntelPCCameraPro,
IntelCreateAndShare,
......
PhilipsDMVC1300K,
LogitechQC_EasyCool, // added by aaron
LastCamera
};
static struct cam_list clist[] = {
{UnknownCamera, "Unknown"},
{IntelPCCameraPro, "Intel PC Camera Pro"},
{IntelCreateAndShare, "Intel Create and Share"},
......
{PhilipsDMVC1300K,"Philips DMVC 1300K"},
{LogitechQC_EasyCool,"Logitech QuickCam Easy_Cool"}, //added by aaron
{-1, NULL}
};
static __devinitdata struct usb_device_id device_table[] = {
{USB_DEVICE(0x0733, 0x0430)}, /*Intel PC Camera Pro*/
{USB_DEVICE(0x0733, 0x0401)}, /* Intel Create and Share */
......
{USB_DEVICE(0x0471, 0x0322)}, /* Philips DMVC1300K */
{USB_DEVICE(0x046d, 0x08af)},
/* Logitech QuickCam Easy_Cool, added by aaron */
{USB_DEVICE(0x0000, 0x0000)}, /* MystFromOri Unknow Camera */
{} /* Terminating entry */
};
static int
gspca_attach_bridge(struct usb_spca50x *spca50x)
{
/* set the default epadr */
spca50x->epadr =1;
switch (spca50x->bridge) {
......
case BRIDGE_ZC3XX:
spca50x->cameratype = JPGH;
info("USB GSPCA camera found.(ZC3XX) ");
memcpy(&spca50x->funct, &fzc3xx, sizeof (struct cam_operation));
break;
...... //other DSP bridges
default:
return -ENODEV;
}
return 0;
}
检测摄像头型号: static int
spcaDetectCamera(struct usb_spca50x *spca50x)
{
struct usb_device *dev = spca50x->dev;
__u8 fw = 0;
__u16 vendor;
__u16 product;
/* Is it a recognised camera ? */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11)
vendor = le16_to_cpu(dev->descriptor.idVendor);
product = le16_to_cpu(dev->descriptor.idProduct);
#else
vendor = dev->descriptor.idVendor;
product = dev->descriptor.idProduct;
#endif
switch (vendor) {
case 0x046d: /* Logitech Labtec */
switch (product) {
case 0x08af: //added by aaron
spca50x->desc = LogitechQC_EasyCool;
spca50x->bridge = BRIDGE_ZC3XX;
spca50x->sensor = SENSOR_HV7131B;
break;
......
case 0x08a0:
spca50x->desc = QCim;
spca50x->bridge = BRIDGE_ZC3XX;
spca50x->sensor = SENSOR_TAS5130CXX;
break;
case 0x08a1:
spca50x->desc = QCimA1;
spca50x->bridge = BRIDGE_ZC3XX;
spca50x->sensor = SENSOR_TAS5130CXX;
break;
case 0x08a2: // zc302 chips
spca50x->desc = LabtecPro;
spca50x->bridge = BRIDGE_ZC3XX;
spca50x->sensor = SENSOR_HDCS2020;
break;
case 0x08a3:
spca50x->desc = QCchat;
spca50x->bridge = BRIDGE_ZC3XX;
spca50x->sensor = SENSOR_TAS5130CXX;
break;
case 0x08a6:
spca50x->desc = LogitechQCim;
spca50x->bridge = BRIDGE_ZC3XX;
spca50x->sensor = SENSOR_HV7131C;
break;
case 0x08a7:
spca50x->desc = LogitechQCImage;
spca50x->bridge = BRIDGE_ZC3XX;
spca50x->sensor = SENSOR_PAS202;
break;
case 0x08d8:
case 0x08a9:
spca50x->desc = LogitechNotebookDeluxe;
spca50x->bridge = BRIDGE_ZC3XX;
spca50x->sensor = SENSOR_HDCS2020;
break;
case 0x08ae:
spca50x->desc = QuickCamNB;
spca50x->bridge = BRIDGE_ZC3XX;
spca50x->sensor = SENSOR_HDCS2020;
break;
case 0x08ac:
spca50x->desc = LogitechQCCool;
spca50x->bridge = BRIDGE_ZC3XX;
spca50x->sensor = SENSOR_HV7131B;
break;
......
default:
goto error;
};
break;
...... //other vendors
return gspca_attach_bridge(spca50x);
error:
return -ENODEV; //no camera match
}
static int
spca5xx_probe(struct usb_interface *intf, const struct usb_device_id *id){
......
if ((err_probe = spcaDetectCamera(spca50x)) < 0) {
err(" Devices not found !! ");
goto error;
}
......
}
到此,我们对gspca驱动程序的扩展就算完成了。在函数spcaDetectCamera()中的switch结构中,将我们的摄像头放到第一个case,是为了在探测摄像头时第一个就找到我们的摄像头,提高检测速度。
需要指出两点,一是在函数spcaDetectCamera()中,我们假定Logitech QC Easy/Cool的CMOS传感器型号为SENSOR_HV7131B,这需要在后续的实验中进行验证;二是spca5xx_probe()函数中,红色代码部分,实际上调用了spcaDetectCamera()函数来探测摄像头,如果出错则报错" Devices not found !! "并退出,由于之前gspca中没有Easy/Cool摄像头的信息,因此,之前即使自己创建了/dev/video0等设备文件,还是会报错“找不到设备”。
|
|