diff options
author | Jean-Francois Moine <moinejf@free.fr> | 2008-12-29 04:19:43 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-12-30 06:40:06 -0500 |
commit | 15f64864e392612b230bc71d84e4537b80c607b1 (patch) | |
tree | 1870925039977cb727c4866159118d949a2b4cc8 /drivers/media | |
parent | f367b85d9a0bda04c31c5c5598dba758efc6658e (diff) |
V4L/DVB (10046): gspca - ov534: Use the gspca usb buf for usb control messages.
Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/gspca/ov534.c | 104 |
1 files changed, 53 insertions, 51 deletions
diff --git a/drivers/media/video/gspca/ov534.c b/drivers/media/video/gspca/ov534.c index d5c74d65ce8a..406f6bc12d9f 100644 --- a/drivers/media/video/gspca/ov534.c +++ b/drivers/media/video/gspca/ov534.c | |||
@@ -63,65 +63,66 @@ static struct v4l2_pix_format vga_mode[] = { | |||
63 | .priv = 0}, | 63 | .priv = 0}, |
64 | }; | 64 | }; |
65 | 65 | ||
66 | static void ov534_reg_write(struct usb_device *udev, u16 reg, u8 val) | 66 | static void ov534_reg_write(struct gspca_dev *gspca_dev, u16 reg, u8 val) |
67 | { | 67 | { |
68 | u8 data = val; | 68 | struct usb_device *udev = gspca_dev->dev; |
69 | int ret; | 69 | int ret; |
70 | 70 | ||
71 | PDEBUG(D_USBO, "reg=0x%04x, val=0%02x", reg, val); | 71 | PDEBUG(D_USBO, "reg=0x%04x, val=0%02x", reg, val); |
72 | gspca_dev->usb_buf[0] = val; | ||
72 | ret = usb_control_msg(udev, | 73 | ret = usb_control_msg(udev, |
73 | usb_sndctrlpipe(udev, 0), | 74 | usb_sndctrlpipe(udev, 0), |
74 | 0x1, | 75 | 0x1, |
75 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 76 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
76 | 0x0, reg, &data, 1, CTRL_TIMEOUT); | 77 | 0x0, reg, gspca_dev->usb_buf, 1, CTRL_TIMEOUT); |
77 | if (ret < 0) | 78 | if (ret < 0) |
78 | PDEBUG(D_ERR, "write failed"); | 79 | PDEBUG(D_ERR, "write failed"); |
79 | } | 80 | } |
80 | 81 | ||
81 | static u8 ov534_reg_read(struct usb_device *udev, u16 reg) | 82 | static u8 ov534_reg_read(struct gspca_dev *gspca_dev, u16 reg) |
82 | { | 83 | { |
83 | u8 data; | 84 | struct usb_device *udev = gspca_dev->dev; |
84 | int ret; | 85 | int ret; |
85 | 86 | ||
86 | ret = usb_control_msg(udev, | 87 | ret = usb_control_msg(udev, |
87 | usb_rcvctrlpipe(udev, 0), | 88 | usb_rcvctrlpipe(udev, 0), |
88 | 0x1, | 89 | 0x1, |
89 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 90 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
90 | 0x0, reg, &data, 1, CTRL_TIMEOUT); | 91 | 0x0, reg, gspca_dev->usb_buf, 1, CTRL_TIMEOUT); |
91 | PDEBUG(D_USBI, "reg=0x%04x, data=0x%02x", reg, data); | 92 | PDEBUG(D_USBI, "reg=0x%04x, data=0x%02x", reg, gspca_dev->usb_buf[0]); |
92 | if (ret < 0) | 93 | if (ret < 0) |
93 | PDEBUG(D_ERR, "read failed"); | 94 | PDEBUG(D_ERR, "read failed"); |
94 | return data; | 95 | return gspca_dev->usb_buf[0]; |
95 | } | 96 | } |
96 | 97 | ||
97 | /* Two bits control LED: 0x21 bit 7 and 0x23 bit 7. | 98 | /* Two bits control LED: 0x21 bit 7 and 0x23 bit 7. |
98 | * (direction and output)? */ | 99 | * (direction and output)? */ |
99 | static void ov534_set_led(struct usb_device *udev, int status) | 100 | static void ov534_set_led(struct gspca_dev *gspca_dev, int status) |
100 | { | 101 | { |
101 | u8 data; | 102 | u8 data; |
102 | 103 | ||
103 | PDEBUG(D_CONF, "led status: %d", status); | 104 | PDEBUG(D_CONF, "led status: %d", status); |
104 | 105 | ||
105 | data = ov534_reg_read(udev, 0x21); | 106 | data = ov534_reg_read(gspca_dev, 0x21); |
106 | data |= 0x80; | 107 | data |= 0x80; |
107 | ov534_reg_write(udev, 0x21, data); | 108 | ov534_reg_write(gspca_dev, 0x21, data); |
108 | 109 | ||
109 | data = ov534_reg_read(udev, 0x23); | 110 | data = ov534_reg_read(gspca_dev, 0x23); |
110 | if (status) | 111 | if (status) |
111 | data |= 0x80; | 112 | data |= 0x80; |
112 | else | 113 | else |
113 | data &= ~(0x80); | 114 | data &= ~(0x80); |
114 | 115 | ||
115 | ov534_reg_write(udev, 0x23, data); | 116 | ov534_reg_write(gspca_dev, 0x23, data); |
116 | } | 117 | } |
117 | 118 | ||
118 | static int sccb_check_status(struct usb_device *udev) | 119 | static int sccb_check_status(struct gspca_dev *gspca_dev) |
119 | { | 120 | { |
120 | u8 data; | 121 | u8 data; |
121 | int i; | 122 | int i; |
122 | 123 | ||
123 | for (i = 0; i < 5; i++) { | 124 | for (i = 0; i < 5; i++) { |
124 | data = ov534_reg_read(udev, OV534_REG_STATUS); | 125 | data = ov534_reg_read(gspca_dev, OV534_REG_STATUS); |
125 | 126 | ||
126 | switch (data) { | 127 | switch (data) { |
127 | case 0x00: | 128 | case 0x00: |
@@ -138,30 +139,30 @@ static int sccb_check_status(struct usb_device *udev) | |||
138 | return 0; | 139 | return 0; |
139 | } | 140 | } |
140 | 141 | ||
141 | static void sccb_reg_write(struct usb_device *udev, u16 reg, u8 val) | 142 | static void sccb_reg_write(struct gspca_dev *gspca_dev, u16 reg, u8 val) |
142 | { | 143 | { |
143 | PDEBUG(D_USBO, "reg: 0x%04x, val: 0x%02x", reg, val); | 144 | PDEBUG(D_USBO, "reg: 0x%04x, val: 0x%02x", reg, val); |
144 | ov534_reg_write(udev, OV534_REG_SUBADDR, reg); | 145 | ov534_reg_write(gspca_dev, OV534_REG_SUBADDR, reg); |
145 | ov534_reg_write(udev, OV534_REG_WRITE, val); | 146 | ov534_reg_write(gspca_dev, OV534_REG_WRITE, val); |
146 | ov534_reg_write(udev, OV534_REG_OPERATION, OV534_OP_WRITE_3); | 147 | ov534_reg_write(gspca_dev, OV534_REG_OPERATION, OV534_OP_WRITE_3); |
147 | 148 | ||
148 | if (!sccb_check_status(udev)) | 149 | if (!sccb_check_status(gspca_dev)) |
149 | PDEBUG(D_ERR, "sccb_reg_write failed"); | 150 | PDEBUG(D_ERR, "sccb_reg_write failed"); |
150 | } | 151 | } |
151 | 152 | ||
152 | #ifdef GSPCA_DEBUG | 153 | #ifdef GSPCA_DEBUG |
153 | static u8 sccb_reg_read(struct usb_device *udev, u16 reg) | 154 | static u8 sccb_reg_read(struct gspca_dev *gspca_dev, u16 reg) |
154 | { | 155 | { |
155 | ov534_reg_write(udev, OV534_REG_SUBADDR, reg); | 156 | ov534_reg_write(gspca_dev, OV534_REG_SUBADDR, reg); |
156 | ov534_reg_write(udev, OV534_REG_OPERATION, OV534_OP_WRITE_2); | 157 | ov534_reg_write(gspca_dev, OV534_REG_OPERATION, OV534_OP_WRITE_2); |
157 | if (!sccb_check_status(udev)) | 158 | if (!sccb_check_status(gspca_dev)) |
158 | PDEBUG(D_ERR, "sccb_reg_read failed 1"); | 159 | PDEBUG(D_ERR, "sccb_reg_read failed 1"); |
159 | 160 | ||
160 | ov534_reg_write(udev, OV534_REG_OPERATION, OV534_OP_READ_2); | 161 | ov534_reg_write(gspca_dev, OV534_REG_OPERATION, OV534_OP_READ_2); |
161 | if (!sccb_check_status(udev)) | 162 | if (!sccb_check_status(gspca_dev)) |
162 | PDEBUG(D_ERR, "sccb_reg_read failed 2"); | 163 | PDEBUG(D_ERR, "sccb_reg_read failed 2"); |
163 | 164 | ||
164 | return ov534_reg_read(udev, OV534_REG_READ); | 165 | return ov534_reg_read(gspca_dev, OV534_REG_READ); |
165 | } | 166 | } |
166 | #endif | 167 | #endif |
167 | 168 | ||
@@ -318,26 +319,26 @@ static void ov534_set_frame_rate(struct gspca_dev *gspca_dev) | |||
318 | 319 | ||
319 | switch (fr) { | 320 | switch (fr) { |
320 | case 50: | 321 | case 50: |
321 | sccb_reg_write(gspca_dev->dev, 0x11, 0x01); | 322 | sccb_reg_write(gspca_dev, 0x11, 0x01); |
322 | sccb_reg_write(gspca_dev->dev, 0x0d, 0x41); | 323 | sccb_reg_write(gspca_dev, 0x0d, 0x41); |
323 | ov534_reg_write(gspca_dev->dev, 0xe5, 0x02); | 324 | ov534_reg_write(gspca_dev, 0xe5, 0x02); |
324 | break; | 325 | break; |
325 | case 40: | 326 | case 40: |
326 | sccb_reg_write(gspca_dev->dev, 0x11, 0x02); | 327 | sccb_reg_write(gspca_dev, 0x11, 0x02); |
327 | sccb_reg_write(gspca_dev->dev, 0x0d, 0xc1); | 328 | sccb_reg_write(gspca_dev, 0x0d, 0xc1); |
328 | ov534_reg_write(gspca_dev->dev, 0xe5, 0x04); | 329 | ov534_reg_write(gspca_dev, 0xe5, 0x04); |
329 | break; | 330 | break; |
330 | /* case 30: */ | 331 | /* case 30: */ |
331 | default: | 332 | default: |
332 | fr = 30; | 333 | fr = 30; |
333 | sccb_reg_write(gspca_dev->dev, 0x11, 0x04); | 334 | sccb_reg_write(gspca_dev, 0x11, 0x04); |
334 | sccb_reg_write(gspca_dev->dev, 0x0d, 0x81); | 335 | sccb_reg_write(gspca_dev, 0x0d, 0x81); |
335 | ov534_reg_write(gspca_dev->dev, 0xe5, 0x02); | 336 | ov534_reg_write(gspca_dev, 0xe5, 0x02); |
336 | break; | 337 | break; |
337 | case 15: | 338 | case 15: |
338 | sccb_reg_write(gspca_dev->dev, 0x11, 0x03); | 339 | sccb_reg_write(gspca_dev, 0x11, 0x03); |
339 | sccb_reg_write(gspca_dev->dev, 0x0d, 0x41); | 340 | sccb_reg_write(gspca_dev, 0x0d, 0x41); |
340 | ov534_reg_write(gspca_dev->dev, 0xe5, 0x04); | 341 | ov534_reg_write(gspca_dev, 0xe5, 0x04); |
341 | break; | 342 | break; |
342 | } | 343 | } |
343 | 344 | ||
@@ -346,27 +347,28 @@ static void ov534_set_frame_rate(struct gspca_dev *gspca_dev) | |||
346 | } | 347 | } |
347 | 348 | ||
348 | /* setup method */ | 349 | /* setup method */ |
349 | static void ov534_setup(struct usb_device *udev) | 350 | static void ov534_setup(struct gspca_dev *gspca_dev) |
350 | { | 351 | { |
351 | int i; | 352 | int i; |
352 | 353 | ||
353 | /* Initialize bridge chip */ | 354 | /* Initialize bridge chip */ |
354 | for (i = 0; i < ARRAY_SIZE(ov534_reg_initdata); i++) | 355 | for (i = 0; i < ARRAY_SIZE(ov534_reg_initdata); i++) |
355 | ov534_reg_write(udev, ov534_reg_initdata[i][0], | 356 | ov534_reg_write(gspca_dev, ov534_reg_initdata[i][0], |
356 | ov534_reg_initdata[i][1]); | 357 | ov534_reg_initdata[i][1]); |
357 | 358 | ||
358 | PDEBUG(D_PROBE, "sensor is ov%02x%02x", | 359 | PDEBUG(D_PROBE, "sensor is ov%02x%02x", |
359 | sccb_reg_read(udev, 0x0a), sccb_reg_read(udev, 0x0b)); | 360 | sccb_reg_read(gspca_dev, 0x0a), |
361 | sccb_reg_read(gspca_dev, 0x0b)); | ||
360 | 362 | ||
361 | ov534_set_led(udev, 1); | 363 | ov534_set_led(gspca_dev, 1); |
362 | 364 | ||
363 | /* Initialize sensor */ | 365 | /* Initialize sensor */ |
364 | for (i = 0; i < ARRAY_SIZE(ov772x_reg_initdata); i++) | 366 | for (i = 0; i < ARRAY_SIZE(ov772x_reg_initdata); i++) |
365 | sccb_reg_write(udev, ov772x_reg_initdata[i][0], | 367 | sccb_reg_write(gspca_dev, ov772x_reg_initdata[i][0], |
366 | ov772x_reg_initdata[i][1]); | 368 | ov772x_reg_initdata[i][1]); |
367 | 369 | ||
368 | ov534_reg_write(udev, 0xe0, 0x09); | 370 | ov534_reg_write(gspca_dev, 0xe0, 0x09); |
369 | ov534_set_led(udev, 0); | 371 | ov534_set_led(gspca_dev, 0); |
370 | } | 372 | } |
371 | 373 | ||
372 | /* this function is called at probe time */ | 374 | /* this function is called at probe time */ |
@@ -390,7 +392,7 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
390 | /* this function is called at probe and resume time */ | 392 | /* this function is called at probe and resume time */ |
391 | static int sd_init(struct gspca_dev *gspca_dev) | 393 | static int sd_init(struct gspca_dev *gspca_dev) |
392 | { | 394 | { |
393 | ov534_setup(gspca_dev->dev); | 395 | ov534_setup(gspca_dev); |
394 | ov534_set_frame_rate(gspca_dev); | 396 | ov534_set_frame_rate(gspca_dev); |
395 | 397 | ||
396 | return 0; | 398 | return 0; |
@@ -399,8 +401,8 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
399 | static int sd_start(struct gspca_dev *gspca_dev) | 401 | static int sd_start(struct gspca_dev *gspca_dev) |
400 | { | 402 | { |
401 | /* start streaming data */ | 403 | /* start streaming data */ |
402 | ov534_set_led(gspca_dev->dev, 1); | 404 | ov534_set_led(gspca_dev, 1); |
403 | ov534_reg_write(gspca_dev->dev, 0xe0, 0x00); | 405 | ov534_reg_write(gspca_dev, 0xe0, 0x00); |
404 | 406 | ||
405 | return 0; | 407 | return 0; |
406 | } | 408 | } |
@@ -408,8 +410,8 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
408 | static void sd_stopN(struct gspca_dev *gspca_dev) | 410 | static void sd_stopN(struct gspca_dev *gspca_dev) |
409 | { | 411 | { |
410 | /* stop streaming data */ | 412 | /* stop streaming data */ |
411 | ov534_reg_write(gspca_dev->dev, 0xe0, 0x09); | 413 | ov534_reg_write(gspca_dev, 0xe0, 0x09); |
412 | ov534_set_led(gspca_dev->dev, 0); | 414 | ov534_set_led(gspca_dev, 0); |
413 | } | 415 | } |
414 | 416 | ||
415 | /* Values for bmHeaderInfo (Video and Still Image Payload Headers, 2.4.3.3) */ | 417 | /* Values for bmHeaderInfo (Video and Still Image Payload Headers, 2.4.3.3) */ |