diff options
author | Pete Eberlein <pete@sensoray.com> | 2009-11-16 13:07:42 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-12-05 15:42:00 -0500 |
commit | 0b398f4f124e2b4b03f9acf726370c8459610c5c (patch) | |
tree | e391f4794df042eb50f228663d9df720adc1db60 /drivers | |
parent | 76dd272b56cd1c7fa013ef5d7eb28c4d319e322b (diff) |
V4L/DVB (13455): go7007: Add struct v4l2_device.
This adds a struct v4l2_device to the go7007 device struct and registers
it during v4l2 initialization. The v4l2_device registration overwrites
the go->dev device_data, which is a struct usb_interface with intfdata set
to the struct go7007. This changes intfdata to point to the struct
v4l2_device inside struct go7007, which is what v4l2_device_register will
also set it to (and warn about non-null drvdata on register.) Since usb
disconnect can happen any time, this intfdata should always be present.
Signed-off-by: Pete Eberlein <pete@sensoray.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/go7007/go7007-driver.c | 10 | ||||
-rw-r--r-- | drivers/staging/go7007/go7007-priv.h | 8 | ||||
-rw-r--r-- | drivers/staging/go7007/go7007-usb.c | 4 | ||||
-rw-r--r-- | drivers/staging/go7007/go7007-v4l2.c | 9 |
4 files changed, 23 insertions, 8 deletions
diff --git a/drivers/staging/go7007/go7007-driver.c b/drivers/staging/go7007/go7007-driver.c index 472f4bb08fdc..869430ec0319 100644 --- a/drivers/staging/go7007/go7007-driver.c +++ b/drivers/staging/go7007/go7007-driver.c | |||
@@ -49,7 +49,7 @@ int go7007_read_interrupt(struct go7007 *go, u16 *value, u16 *data) | |||
49 | go->hpi_ops->read_interrupt(go); | 49 | go->hpi_ops->read_interrupt(go); |
50 | if (wait_event_timeout(go->interrupt_waitq, | 50 | if (wait_event_timeout(go->interrupt_waitq, |
51 | go->interrupt_available, 5*HZ) < 0) { | 51 | go->interrupt_available, 5*HZ) < 0) { |
52 | v4l2_err(go->video_dev, "timeout waiting for read interrupt\n"); | 52 | v4l2_err(&go->v4l2_dev, "timeout waiting for read interrupt\n"); |
53 | return -1; | 53 | return -1; |
54 | } | 54 | } |
55 | if (!go->interrupt_available) | 55 | if (!go->interrupt_available) |
@@ -315,7 +315,7 @@ int go7007_start_encoder(struct go7007 *go) | |||
315 | 315 | ||
316 | if (go7007_send_firmware(go, fw, fw_len) < 0 || | 316 | if (go7007_send_firmware(go, fw, fw_len) < 0 || |
317 | go7007_read_interrupt(go, &intr_val, &intr_data) < 0) { | 317 | go7007_read_interrupt(go, &intr_val, &intr_data) < 0) { |
318 | v4l2_err(go->video_dev, "error transferring firmware\n"); | 318 | v4l2_err(&go->v4l2_dev, "error transferring firmware\n"); |
319 | rv = -1; | 319 | rv = -1; |
320 | goto start_error; | 320 | goto start_error; |
321 | } | 321 | } |
@@ -324,7 +324,7 @@ int go7007_start_encoder(struct go7007 *go) | |||
324 | go->parse_length = 0; | 324 | go->parse_length = 0; |
325 | go->seen_frame = 0; | 325 | go->seen_frame = 0; |
326 | if (go7007_stream_start(go) < 0) { | 326 | if (go7007_stream_start(go) < 0) { |
327 | v4l2_err(go->video_dev, "error starting stream transfer\n"); | 327 | v4l2_err(&go->v4l2_dev, "error starting stream transfer\n"); |
328 | rv = -1; | 328 | rv = -1; |
329 | goto start_error; | 329 | goto start_error; |
330 | } | 330 | } |
@@ -420,7 +420,7 @@ void go7007_parse_video_stream(struct go7007 *go, u8 *buf, int length) | |||
420 | for (i = 0; i < length; ++i) { | 420 | for (i = 0; i < length; ++i) { |
421 | if (go->active_buf != NULL && | 421 | if (go->active_buf != NULL && |
422 | go->active_buf->bytesused >= GO7007_BUF_SIZE - 3) { | 422 | go->active_buf->bytesused >= GO7007_BUF_SIZE - 3) { |
423 | v4l2_info(go->video_dev, "dropping oversized frame\n"); | 423 | v4l2_info(&go->v4l2_dev, "dropping oversized frame\n"); |
424 | go->active_buf->offset -= go->active_buf->bytesused; | 424 | go->active_buf->offset -= go->active_buf->bytesused; |
425 | go->active_buf->bytesused = 0; | 425 | go->active_buf->bytesused = 0; |
426 | go->active_buf->modet_active = 0; | 426 | go->active_buf->modet_active = 0; |
@@ -668,7 +668,7 @@ void go7007_remove(struct go7007 *go) | |||
668 | if (i2c_del_adapter(&go->i2c_adapter) == 0) | 668 | if (i2c_del_adapter(&go->i2c_adapter) == 0) |
669 | go->i2c_adapter_online = 0; | 669 | go->i2c_adapter_online = 0; |
670 | else | 670 | else |
671 | v4l2_err(go->video_dev, | 671 | v4l2_err(&go->v4l2_dev, |
672 | "error removing I2C adapter!\n"); | 672 | "error removing I2C adapter!\n"); |
673 | } | 673 | } |
674 | 674 | ||
diff --git a/drivers/staging/go7007/go7007-priv.h b/drivers/staging/go7007/go7007-priv.h index ce9307e3e186..b58c394c6555 100644 --- a/drivers/staging/go7007/go7007-priv.h +++ b/drivers/staging/go7007/go7007-priv.h | |||
@@ -21,6 +21,8 @@ | |||
21 | * user-space applications. | 21 | * user-space applications. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <media/v4l2-device.h> | ||
25 | |||
24 | struct go7007; | 26 | struct go7007; |
25 | 27 | ||
26 | /* IDs to activate board-specific support code */ | 28 | /* IDs to activate board-specific support code */ |
@@ -167,6 +169,7 @@ struct go7007 { | |||
167 | int channel_number; /* for multi-channel boards like Adlink PCI-MPG24 */ | 169 | int channel_number; /* for multi-channel boards like Adlink PCI-MPG24 */ |
168 | char name[64]; | 170 | char name[64]; |
169 | struct video_device *video_dev; | 171 | struct video_device *video_dev; |
172 | struct v4l2_device v4l2_dev; | ||
170 | int ref_count; | 173 | int ref_count; |
171 | enum { STATUS_INIT, STATUS_ONLINE, STATUS_SHUTDOWN } status; | 174 | enum { STATUS_INIT, STATUS_ONLINE, STATUS_SHUTDOWN } status; |
172 | spinlock_t spinlock; | 175 | spinlock_t spinlock; |
@@ -240,6 +243,11 @@ struct go7007 { | |||
240 | unsigned short interrupt_data; | 243 | unsigned short interrupt_data; |
241 | }; | 244 | }; |
242 | 245 | ||
246 | static inline struct go7007 *to_go7007(struct v4l2_device *v4l2_dev) | ||
247 | { | ||
248 | return container_of(v4l2_dev, struct go7007, v4l2_dev); | ||
249 | } | ||
250 | |||
243 | /* All of these must be called with the hpi_lock mutex held! */ | 251 | /* All of these must be called with the hpi_lock mutex held! */ |
244 | #define go7007_interface_reset(go) \ | 252 | #define go7007_interface_reset(go) \ |
245 | ((go)->hpi_ops->interface_reset(go)) | 253 | ((go)->hpi_ops->interface_reset(go)) |
diff --git a/drivers/staging/go7007/go7007-usb.c b/drivers/staging/go7007/go7007-usb.c index ecaa3c989cf4..f17e7b337a15 100644 --- a/drivers/staging/go7007/go7007-usb.c +++ b/drivers/staging/go7007/go7007-usb.c | |||
@@ -1057,7 +1057,7 @@ static int go7007_usb_probe(struct usb_interface *intf, | |||
1057 | usb_rcvintpipe(usb->usbdev, 4), | 1057 | usb_rcvintpipe(usb->usbdev, 4), |
1058 | usb->intr_urb->transfer_buffer, 2*sizeof(u16), | 1058 | usb->intr_urb->transfer_buffer, 2*sizeof(u16), |
1059 | go7007_usb_readinterrupt_complete, go, 8); | 1059 | go7007_usb_readinterrupt_complete, go, 8); |
1060 | usb_set_intfdata(intf, go); | 1060 | usb_set_intfdata(intf, &go->v4l2_dev); |
1061 | 1061 | ||
1062 | /* Boot the GO7007 */ | 1062 | /* Boot the GO7007 */ |
1063 | if (go7007_boot_encoder(go, go->board_info->flags & | 1063 | if (go7007_boot_encoder(go, go->board_info->flags & |
@@ -1233,7 +1233,7 @@ allocfail: | |||
1233 | 1233 | ||
1234 | static void go7007_usb_disconnect(struct usb_interface *intf) | 1234 | static void go7007_usb_disconnect(struct usb_interface *intf) |
1235 | { | 1235 | { |
1236 | struct go7007 *go = usb_get_intfdata(intf); | 1236 | struct go7007 *go = to_go7007(usb_get_intfdata(intf)); |
1237 | struct go7007_usb *usb = go->hpi_context; | 1237 | struct go7007_usb *usb = go->hpi_context; |
1238 | struct urb *vurb, *aurb; | 1238 | struct urb *vurb, *aurb; |
1239 | int i; | 1239 | int i; |
diff --git a/drivers/staging/go7007/go7007-v4l2.c b/drivers/staging/go7007/go7007-v4l2.c index 4bd353afa596..faa749dd0356 100644 --- a/drivers/staging/go7007/go7007-v4l2.c +++ b/drivers/staging/go7007/go7007-v4l2.c | |||
@@ -1827,7 +1827,7 @@ int go7007_v4l2_init(struct go7007 *go) | |||
1827 | go->video_dev = video_device_alloc(); | 1827 | go->video_dev = video_device_alloc(); |
1828 | if (go->video_dev == NULL) | 1828 | if (go->video_dev == NULL) |
1829 | return -ENOMEM; | 1829 | return -ENOMEM; |
1830 | memcpy(go->video_dev, &go7007_template, sizeof(go7007_template)); | 1830 | *go->video_dev = go7007_template; |
1831 | go->video_dev->parent = go->dev; | 1831 | go->video_dev->parent = go->dev; |
1832 | rv = video_register_device(go->video_dev, VFL_TYPE_GRABBER, -1); | 1832 | rv = video_register_device(go->video_dev, VFL_TYPE_GRABBER, -1); |
1833 | if (rv < 0) { | 1833 | if (rv < 0) { |
@@ -1835,6 +1835,12 @@ int go7007_v4l2_init(struct go7007 *go) | |||
1835 | go->video_dev = NULL; | 1835 | go->video_dev = NULL; |
1836 | return rv; | 1836 | return rv; |
1837 | } | 1837 | } |
1838 | rv = v4l2_device_register(go->dev, &go->v4l2_dev); | ||
1839 | if (rv < 0) { | ||
1840 | video_device_release(go->video_dev); | ||
1841 | go->video_dev = NULL; | ||
1842 | return rv; | ||
1843 | } | ||
1838 | video_set_drvdata(go->video_dev, go); | 1844 | video_set_drvdata(go->video_dev, go); |
1839 | ++go->ref_count; | 1845 | ++go->ref_count; |
1840 | printk(KERN_INFO "%s: registered device video%d [v4l2]\n", | 1846 | printk(KERN_INFO "%s: registered device video%d [v4l2]\n", |
@@ -1858,4 +1864,5 @@ void go7007_v4l2_remove(struct go7007 *go) | |||
1858 | mutex_unlock(&go->hw_lock); | 1864 | mutex_unlock(&go->hw_lock); |
1859 | if (go->video_dev) | 1865 | if (go->video_dev) |
1860 | video_unregister_device(go->video_dev); | 1866 | video_unregister_device(go->video_dev); |
1867 | v4l2_device_unregister(&go->v4l2_dev); | ||
1861 | } | 1868 | } |