aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/hdpvr/hdpvr-video.c
diff options
context:
space:
mode:
authorJanne Grunau <j@jannau.net>2009-03-27 19:09:40 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-30 11:43:43 -0400
commit9ef77adfb9ac170bcaf449530cf129c48547fd55 (patch)
tree686d2a00fb7e12d5416bf0327f3999612376451d /drivers/media/video/hdpvr/hdpvr-video.c
parent06630aec92d6a71658ac1538e2a65af5cfc5f2af (diff)
V4L/DVB (11246): hdpvr: convert printing macros to v4l2_* with struct v4l2_device
it gives us a nice and unique prefix per device Signed-off-by: Janne Grunau <j@jannau.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/hdpvr/hdpvr-video.c')
-rw-r--r--drivers/media/video/hdpvr/hdpvr-video.c61
1 files changed, 33 insertions, 28 deletions
diff --git a/drivers/media/video/hdpvr/hdpvr-video.c b/drivers/media/video/hdpvr/hdpvr-video.c
index 2fe57303c0b5..f6e1bcefddb7 100644
--- a/drivers/media/video/hdpvr/hdpvr-video.c
+++ b/drivers/media/video/hdpvr/hdpvr-video.c
@@ -28,11 +28,12 @@
28 28
29#define BULK_URB_TIMEOUT 1250 /* 1.25 seconds */ 29#define BULK_URB_TIMEOUT 1250 /* 1.25 seconds */
30 30
31#define print_buffer_status() v4l2_dbg(MSG_BUFFER, hdpvr_debug, dev->video_dev,\ 31#define print_buffer_status() { \
32 "%s:%d buffer stat: %d free, %d proc\n",\ 32 v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev, \
33 __func__, __LINE__, \ 33 "%s:%d buffer stat: %d free, %d proc\n", \
34 list_size(&dev->free_buff_list), \ 34 __func__, __LINE__, \
35 list_size(&dev->rec_buff_list)) 35 list_size(&dev->free_buff_list), \
36 list_size(&dev->rec_buff_list)); }
36 37
37struct hdpvr_fh { 38struct hdpvr_fh {
38 struct hdpvr_device *dev; 39 struct hdpvr_device *dev;
@@ -123,21 +124,21 @@ int hdpvr_alloc_buffers(struct hdpvr_device *dev, uint count)
123 struct hdpvr_buffer *buf; 124 struct hdpvr_buffer *buf;
124 struct urb *urb; 125 struct urb *urb;
125 126
126 v4l2_dbg(MSG_INFO, hdpvr_debug, dev->video_dev, 127 v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev,
127 "allocating %u buffers\n", count); 128 "allocating %u buffers\n", count);
128 129
129 for (i = 0; i < count; i++) { 130 for (i = 0; i < count; i++) {
130 131
131 buf = kzalloc(sizeof(struct hdpvr_buffer), GFP_KERNEL); 132 buf = kzalloc(sizeof(struct hdpvr_buffer), GFP_KERNEL);
132 if (!buf) { 133 if (!buf) {
133 err("cannot allocate buffer"); 134 v4l2_err(&dev->v4l2_dev, "cannot allocate buffer\n");
134 goto exit; 135 goto exit;
135 } 136 }
136 buf->dev = dev; 137 buf->dev = dev;
137 138
138 urb = usb_alloc_urb(0, GFP_KERNEL); 139 urb = usb_alloc_urb(0, GFP_KERNEL);
139 if (!urb) { 140 if (!urb) {
140 err("cannot allocate urb"); 141 v4l2_err(&dev->v4l2_dev, "cannot allocate urb\n");
141 goto exit; 142 goto exit;
142 } 143 }
143 buf->urb = urb; 144 buf->urb = urb;
@@ -145,7 +146,8 @@ int hdpvr_alloc_buffers(struct hdpvr_device *dev, uint count)
145 mem = usb_buffer_alloc(dev->udev, dev->bulk_in_size, GFP_KERNEL, 146 mem = usb_buffer_alloc(dev->udev, dev->bulk_in_size, GFP_KERNEL,
146 &urb->transfer_dma); 147 &urb->transfer_dma);
147 if (!mem) { 148 if (!mem) {
148 err("cannot allocate usb transfer buffer"); 149 v4l2_err(&dev->v4l2_dev,
150 "cannot allocate usb transfer buffer\n");
149 goto exit; 151 goto exit;
150 } 152 }
151 153
@@ -178,7 +180,8 @@ static int hdpvr_submit_buffers(struct hdpvr_device *dev)
178 buf = list_entry(dev->free_buff_list.next, struct hdpvr_buffer, 180 buf = list_entry(dev->free_buff_list.next, struct hdpvr_buffer,
179 buff_list); 181 buff_list);
180 if (buf->status != BUFSTAT_AVAILABLE) { 182 if (buf->status != BUFSTAT_AVAILABLE) {
181 err("buffer not marked as availbale"); 183 v4l2_err(&dev->v4l2_dev,
184 "buffer not marked as availbale\n");
182 ret = -EFAULT; 185 ret = -EFAULT;
183 goto err; 186 goto err;
184 } 187 }
@@ -188,7 +191,9 @@ static int hdpvr_submit_buffers(struct hdpvr_device *dev)
188 urb->actual_length = 0; 191 urb->actual_length = 0;
189 ret = usb_submit_urb(urb, GFP_KERNEL); 192 ret = usb_submit_urb(urb, GFP_KERNEL);
190 if (ret) { 193 if (ret) {
191 err("usb_submit_urb in %s returned %d", __func__, ret); 194 v4l2_err(&dev->v4l2_dev,
195 "usb_submit_urb in %s returned %d\n",
196 __func__, ret);
192 if (++err_count > 2) 197 if (++err_count > 2)
193 break; 198 break;
194 continue; 199 continue;
@@ -228,7 +233,7 @@ static void hdpvr_transmit_buffers(struct work_struct *work)
228 while (dev->status == STATUS_STREAMING) { 233 while (dev->status == STATUS_STREAMING) {
229 234
230 if (hdpvr_submit_buffers(dev)) { 235 if (hdpvr_submit_buffers(dev)) {
231 v4l2_err(dev->video_dev, "couldn't submit buffers\n"); 236 v4l2_err(&dev->v4l2_dev, "couldn't submit buffers\n");
232 goto error; 237 goto error;
233 } 238 }
234 if (wait_event_interruptible(dev->wait_buffer, 239 if (wait_event_interruptible(dev->wait_buffer,
@@ -237,11 +242,11 @@ static void hdpvr_transmit_buffers(struct work_struct *work)
237 goto error; 242 goto error;
238 } 243 }
239 244
240 v4l2_dbg(MSG_INFO, hdpvr_debug, dev->video_dev, 245 v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev,
241 "transmit worker exited\n"); 246 "transmit worker exited\n");
242 return; 247 return;
243error: 248error:
244 v4l2_dbg(MSG_INFO, hdpvr_debug, dev->video_dev, 249 v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev,
245 "transmit buffers errored\n"); 250 "transmit buffers errored\n");
246 dev->status = STATUS_ERROR; 251 dev->status = STATUS_ERROR;
247} 252}
@@ -260,7 +265,7 @@ static int hdpvr_start_streaming(struct hdpvr_device *dev)
260 vidinf = get_video_info(dev); 265 vidinf = get_video_info(dev);
261 266
262 if (vidinf) { 267 if (vidinf) {
263 v4l2_dbg(MSG_BUFFER, hdpvr_debug, dev->video_dev, 268 v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev,
264 "video signal: %dx%d@%dhz\n", vidinf->width, 269 "video signal: %dx%d@%dhz\n", vidinf->width,
265 vidinf->height, vidinf->fps); 270 vidinf->height, vidinf->fps);
266 kfree(vidinf); 271 kfree(vidinf);
@@ -269,7 +274,7 @@ static int hdpvr_start_streaming(struct hdpvr_device *dev)
269 ret = usb_control_msg(dev->udev, 274 ret = usb_control_msg(dev->udev,
270 usb_sndctrlpipe(dev->udev, 0), 275 usb_sndctrlpipe(dev->udev, 0),
271 0xb8, 0x38, 0x1, 0, NULL, 0, 8000); 276 0xb8, 0x38, 0x1, 0, NULL, 0, 8000);
272 v4l2_dbg(MSG_BUFFER, hdpvr_debug, dev->video_dev, 277 v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev,
273 "encoder start control request returned %d\n", ret); 278 "encoder start control request returned %d\n", ret);
274 279
275 hdpvr_config_call(dev, CTRL_START_STREAMING_VALUE, 0x00); 280 hdpvr_config_call(dev, CTRL_START_STREAMING_VALUE, 0x00);
@@ -277,14 +282,14 @@ static int hdpvr_start_streaming(struct hdpvr_device *dev)
277 INIT_WORK(&dev->worker, hdpvr_transmit_buffers); 282 INIT_WORK(&dev->worker, hdpvr_transmit_buffers);
278 queue_work(dev->workqueue, &dev->worker); 283 queue_work(dev->workqueue, &dev->worker);
279 284
280 v4l2_dbg(MSG_BUFFER, hdpvr_debug, dev->video_dev, 285 v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev,
281 "streaming started\n"); 286 "streaming started\n");
282 dev->status = STATUS_STREAMING; 287 dev->status = STATUS_STREAMING;
283 288
284 return 0; 289 return 0;
285 } 290 }
286 msleep(250); 291 msleep(250);
287 v4l2_dbg(MSG_INFO, hdpvr_debug, dev->video_dev, 292 v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev,
288 "no video signal at input %d\n", dev->options.video_input); 293 "no video signal at input %d\n", dev->options.video_input);
289 return -EAGAIN; 294 return -EAGAIN;
290} 295}
@@ -330,14 +335,14 @@ static int hdpvr_open(struct file *file)
330 335
331 dev = (struct hdpvr_device *)video_get_drvdata(video_devdata(file)); 336 dev = (struct hdpvr_device *)video_get_drvdata(video_devdata(file));
332 if (!dev) { 337 if (!dev) {
333 err("open failing with with ENODEV"); 338 v4l2_err(&dev->v4l2_dev, "open failing with with ENODEV\n");
334 retval = -ENODEV; 339 retval = -ENODEV;
335 goto err; 340 goto err;
336 } 341 }
337 342
338 fh = kzalloc(sizeof(struct hdpvr_fh), GFP_KERNEL); 343 fh = kzalloc(sizeof(struct hdpvr_fh), GFP_KERNEL);
339 if (!fh) { 344 if (!fh) {
340 err("Out of memory?"); 345 v4l2_err(&dev->v4l2_dev, "Out of memory\n");
341 goto err; 346 goto err;
342 } 347 }
343 /* lock the device to allow correctly handling errors 348 /* lock the device to allow correctly handling errors
@@ -396,8 +401,8 @@ static ssize_t hdpvr_read(struct file *file, char __user *buffer, size_t count,
396 mutex_lock(&dev->io_mutex); 401 mutex_lock(&dev->io_mutex);
397 if (dev->status == STATUS_IDLE) { 402 if (dev->status == STATUS_IDLE) {
398 if (hdpvr_start_streaming(dev)) { 403 if (hdpvr_start_streaming(dev)) {
399 v4l2_dbg(MSG_INFO, hdpvr_debug, dev->video_dev, 404 v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev,
400 "start_streaming failed"); 405 "start_streaming failed\n");
401 ret = -EIO; 406 ret = -EIO;
402 msleep(200); 407 msleep(200);
403 dev->status = STATUS_IDLE; 408 dev->status = STATUS_IDLE;
@@ -445,7 +450,7 @@ static ssize_t hdpvr_read(struct file *file, char __user *buffer, size_t count,
445 450
446 if (copy_to_user(buffer, urb->transfer_buffer + buf->pos, 451 if (copy_to_user(buffer, urb->transfer_buffer + buf->pos,
447 cnt)) { 452 cnt)) {
448 err("read: copy_to_user failed"); 453 v4l2_err(&dev->v4l2_dev, "read: copy_to_user failed\n");
449 if (!ret) 454 if (!ret)
450 ret = -EFAULT; 455 ret = -EFAULT;
451 goto err; 456 goto err;
@@ -493,8 +498,8 @@ static unsigned int hdpvr_poll(struct file *filp, poll_table *wait)
493 498
494 if (dev->status == STATUS_IDLE) { 499 if (dev->status == STATUS_IDLE) {
495 if (hdpvr_start_streaming(dev)) { 500 if (hdpvr_start_streaming(dev)) {
496 v4l2_dbg(MSG_BUFFER, hdpvr_debug, dev->video_dev, 501 v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev,
497 "start_streaming failed"); 502 "start_streaming failed\n");
498 dev->status = STATUS_IDLE; 503 dev->status = STATUS_IDLE;
499 } 504 }
500 505
@@ -1130,7 +1135,7 @@ static int vidioc_encoder_cmd(struct file *filp, void *priv,
1130 res = hdpvr_stop_streaming(dev); 1135 res = hdpvr_stop_streaming(dev);
1131 break; 1136 break;
1132 default: 1137 default:
1133 v4l2_dbg(MSG_INFO, hdpvr_debug, dev->video_dev, 1138 v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev,
1134 "Unsupported encoder cmd %d\n", a->cmd); 1139 "Unsupported encoder cmd %d\n", a->cmd);
1135 res = -EINVAL; 1140 res = -EINVAL;
1136 } 1141 }
@@ -1197,7 +1202,7 @@ int hdpvr_register_videodev(struct hdpvr_device *dev, struct device *parent,
1197 /* setup and register video device */ 1202 /* setup and register video device */
1198 dev->video_dev = video_device_alloc(); 1203 dev->video_dev = video_device_alloc();
1199 if (!dev->video_dev) { 1204 if (!dev->video_dev) {
1200 err("video_device_alloc() failed"); 1205 v4l2_err(&dev->v4l2_dev, "video_device_alloc() failed\n");
1201 goto error; 1206 goto error;
1202 } 1207 }
1203 1208
@@ -1207,7 +1212,7 @@ int hdpvr_register_videodev(struct hdpvr_device *dev, struct device *parent,
1207 video_set_drvdata(dev->video_dev, dev); 1212 video_set_drvdata(dev->video_dev, dev);
1208 1213
1209 if (video_register_device(dev->video_dev, VFL_TYPE_GRABBER, devnum)) { 1214 if (video_register_device(dev->video_dev, VFL_TYPE_GRABBER, devnum)) {
1210 err("V4L2 device registration failed"); 1215 v4l2_err(&dev->v4l2_dev, "video_device registration failed\n");
1211 goto error; 1216 goto error;
1212 } 1217 }
1213 1218