| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * |
|---|
| 3 | 4 | * Support for a cx23417 mpeg encoder via cx231xx host port. |
|---|
| .. | .. |
|---|
| 8 | 9 | * - CX23885/7/8 support |
|---|
| 9 | 10 | * |
|---|
| 10 | 11 | * Includes parts from the ivtv driver( http://ivtv.sourceforge.net/), |
|---|
| 11 | | - * |
|---|
| 12 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 13 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 14 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 15 | | - * (at your option) any later version. |
|---|
| 16 | | - * |
|---|
| 17 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 18 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 19 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 20 | | - * GNU General Public License for more details. |
|---|
| 21 | 12 | */ |
|---|
| 22 | 13 | |
|---|
| 23 | 14 | #include "cx231xx.h" |
|---|
| .. | .. |
|---|
| 68 | 59 | #define MCI_MODE_REGISTER_WRITE 0x100 |
|---|
| 69 | 60 | #define MCI_MODE_MEMORY_READ 0x000 |
|---|
| 70 | 61 | #define MCI_MODE_MEMORY_WRITE 0x4000 |
|---|
| 71 | | - |
|---|
| 72 | | -static unsigned int mpegbufs = 8; |
|---|
| 73 | | -module_param(mpegbufs, int, 0644); |
|---|
| 74 | | -MODULE_PARM_DESC(mpegbufs, "number of mpeg buffers, range 2-32"); |
|---|
| 75 | 62 | |
|---|
| 76 | 63 | static unsigned int mpeglines = 128; |
|---|
| 77 | 64 | module_param(mpeglines, int, 0644); |
|---|
| .. | .. |
|---|
| 1060 | 1047 | p_current_fw = p_fw; |
|---|
| 1061 | 1048 | vfree(p_current_fw); |
|---|
| 1062 | 1049 | p_current_fw = NULL; |
|---|
| 1050 | + vfree(p_buffer); |
|---|
| 1063 | 1051 | uninitGPIO(dev); |
|---|
| 1064 | 1052 | release_firmware(firmware); |
|---|
| 1065 | 1053 | dprintk(1, "Firmware upload successful.\n"); |
|---|
| .. | .. |
|---|
| 1086 | 1074 | return retval; |
|---|
| 1087 | 1075 | } |
|---|
| 1088 | 1076 | return 0; |
|---|
| 1089 | | -} |
|---|
| 1090 | | - |
|---|
| 1091 | | -static void cx231xx_417_check_encoder(struct cx231xx *dev) |
|---|
| 1092 | | -{ |
|---|
| 1093 | | - u32 status, seq; |
|---|
| 1094 | | - |
|---|
| 1095 | | - status = 0; |
|---|
| 1096 | | - seq = 0; |
|---|
| 1097 | | - cx231xx_api_cmd(dev, CX2341X_ENC_GET_SEQ_END, 0, 2, &status, &seq); |
|---|
| 1098 | | - dprintk(1, "%s() status = %d, seq = %d\n", __func__, status, seq); |
|---|
| 1099 | 1077 | } |
|---|
| 1100 | 1078 | |
|---|
| 1101 | 1079 | static void cx231xx_codec_settings(struct cx231xx *dev) |
|---|
| .. | .. |
|---|
| 1235 | 1213 | |
|---|
| 1236 | 1214 | /* ------------------------------------------------------------------ */ |
|---|
| 1237 | 1215 | |
|---|
| 1238 | | -static int bb_buf_setup(struct videobuf_queue *q, |
|---|
| 1239 | | - unsigned int *count, unsigned int *size) |
|---|
| 1216 | +static int queue_setup(struct vb2_queue *vq, |
|---|
| 1217 | + unsigned int *nbuffers, unsigned int *nplanes, |
|---|
| 1218 | + unsigned int sizes[], struct device *alloc_devs[]) |
|---|
| 1240 | 1219 | { |
|---|
| 1241 | | - struct cx231xx_fh *fh = q->priv_data; |
|---|
| 1220 | + struct cx231xx *dev = vb2_get_drv_priv(vq); |
|---|
| 1221 | + unsigned int size = mpeglinesize * mpeglines; |
|---|
| 1242 | 1222 | |
|---|
| 1243 | | - fh->dev->ts1.ts_packet_size = mpeglinesize; |
|---|
| 1244 | | - fh->dev->ts1.ts_packet_count = mpeglines; |
|---|
| 1223 | + dev->ts1.ts_packet_size = mpeglinesize; |
|---|
| 1224 | + dev->ts1.ts_packet_count = mpeglines; |
|---|
| 1245 | 1225 | |
|---|
| 1246 | | - *size = fh->dev->ts1.ts_packet_size * fh->dev->ts1.ts_packet_count; |
|---|
| 1247 | | - *count = mpegbufs; |
|---|
| 1226 | + if (vq->num_buffers + *nbuffers < CX231XX_MIN_BUF) |
|---|
| 1227 | + *nbuffers = CX231XX_MIN_BUF - vq->num_buffers; |
|---|
| 1228 | + |
|---|
| 1229 | + if (*nplanes) |
|---|
| 1230 | + return sizes[0] < size ? -EINVAL : 0; |
|---|
| 1231 | + *nplanes = 1; |
|---|
| 1232 | + sizes[0] = mpeglinesize * mpeglines; |
|---|
| 1248 | 1233 | |
|---|
| 1249 | 1234 | return 0; |
|---|
| 1250 | | -} |
|---|
| 1251 | | - |
|---|
| 1252 | | -static void free_buffer(struct videobuf_queue *vq, struct cx231xx_buffer *buf) |
|---|
| 1253 | | -{ |
|---|
| 1254 | | - struct cx231xx_fh *fh = vq->priv_data; |
|---|
| 1255 | | - struct cx231xx *dev = fh->dev; |
|---|
| 1256 | | - unsigned long flags = 0; |
|---|
| 1257 | | - |
|---|
| 1258 | | - BUG_ON(in_interrupt()); |
|---|
| 1259 | | - |
|---|
| 1260 | | - spin_lock_irqsave(&dev->video_mode.slock, flags); |
|---|
| 1261 | | - if (dev->USE_ISO) { |
|---|
| 1262 | | - if (dev->video_mode.isoc_ctl.buf == buf) |
|---|
| 1263 | | - dev->video_mode.isoc_ctl.buf = NULL; |
|---|
| 1264 | | - } else { |
|---|
| 1265 | | - if (dev->video_mode.bulk_ctl.buf == buf) |
|---|
| 1266 | | - dev->video_mode.bulk_ctl.buf = NULL; |
|---|
| 1267 | | - } |
|---|
| 1268 | | - spin_unlock_irqrestore(&dev->video_mode.slock, flags); |
|---|
| 1269 | | - videobuf_waiton(vq, &buf->vb, 0, 0); |
|---|
| 1270 | | - videobuf_vmalloc_free(&buf->vb); |
|---|
| 1271 | | - buf->vb.state = VIDEOBUF_NEEDS_INIT; |
|---|
| 1272 | 1235 | } |
|---|
| 1273 | 1236 | |
|---|
| 1274 | 1237 | static void buffer_copy(struct cx231xx *dev, char *data, int len, struct urb *urb, |
|---|
| .. | .. |
|---|
| 1284 | 1247 | return; |
|---|
| 1285 | 1248 | |
|---|
| 1286 | 1249 | buf = list_entry(dma_q->active.next, |
|---|
| 1287 | | - struct cx231xx_buffer, vb.queue); |
|---|
| 1250 | + struct cx231xx_buffer, list); |
|---|
| 1288 | 1251 | dev->video_mode.isoc_ctl.buf = buf; |
|---|
| 1289 | 1252 | dma_q->mpeg_buffer_done = 1; |
|---|
| 1290 | 1253 | } |
|---|
| 1291 | 1254 | /* Fill buffer */ |
|---|
| 1292 | 1255 | buf = dev->video_mode.isoc_ctl.buf; |
|---|
| 1293 | | - vbuf = videobuf_to_vmalloc(&buf->vb); |
|---|
| 1256 | + vbuf = vb2_plane_vaddr(&buf->vb.vb2_buf, 0); |
|---|
| 1294 | 1257 | |
|---|
| 1295 | 1258 | if ((dma_q->mpeg_buffer_completed+len) < |
|---|
| 1296 | 1259 | mpeglines*mpeglinesize) { |
|---|
| .. | .. |
|---|
| 1314 | 1277 | memcpy(vbuf+dma_q->mpeg_buffer_completed, |
|---|
| 1315 | 1278 | data, tail_data); |
|---|
| 1316 | 1279 | |
|---|
| 1317 | | - buf->vb.state = VIDEOBUF_DONE; |
|---|
| 1318 | | - buf->vb.field_count++; |
|---|
| 1319 | | - v4l2_get_timestamp(&buf->vb.ts); |
|---|
| 1320 | | - list_del(&buf->vb.queue); |
|---|
| 1321 | | - wake_up(&buf->vb.done); |
|---|
| 1280 | + buf->vb.vb2_buf.timestamp = ktime_get_ns(); |
|---|
| 1281 | + buf->vb.sequence = dma_q->sequence++; |
|---|
| 1282 | + list_del(&buf->list); |
|---|
| 1283 | + vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE); |
|---|
| 1322 | 1284 | dma_q->mpeg_buffer_completed = 0; |
|---|
| 1323 | 1285 | |
|---|
| 1324 | 1286 | if (len - tail_data > 0) { |
|---|
| .. | .. |
|---|
| 1339 | 1301 | if (list_empty(&dma_q->active)) |
|---|
| 1340 | 1302 | return; |
|---|
| 1341 | 1303 | |
|---|
| 1342 | | - buf = list_entry(dma_q->active.next, |
|---|
| 1343 | | - struct cx231xx_buffer, vb.queue); |
|---|
| 1304 | + buf = list_entry(dma_q->active.next, struct cx231xx_buffer, list); |
|---|
| 1344 | 1305 | |
|---|
| 1345 | 1306 | /* Fill buffer */ |
|---|
| 1346 | | - vbuf = videobuf_to_vmalloc(&buf->vb); |
|---|
| 1307 | + vbuf = vb2_plane_vaddr(&buf->vb.vb2_buf, 0); |
|---|
| 1347 | 1308 | memcpy(vbuf, data, len); |
|---|
| 1348 | | - buf->vb.state = VIDEOBUF_DONE; |
|---|
| 1349 | | - buf->vb.field_count++; |
|---|
| 1350 | | - v4l2_get_timestamp(&buf->vb.ts); |
|---|
| 1351 | | - list_del(&buf->vb.queue); |
|---|
| 1352 | | - wake_up(&buf->vb.done); |
|---|
| 1309 | + buf->vb.sequence = dma_q->sequence++; |
|---|
| 1310 | + buf->vb.vb2_buf.timestamp = ktime_get_ns(); |
|---|
| 1311 | + list_del(&buf->list); |
|---|
| 1312 | + vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE); |
|---|
| 1353 | 1313 | } |
|---|
| 1354 | 1314 | |
|---|
| 1355 | 1315 | static int cx231xx_isoc_copy(struct cx231xx *dev, struct urb *urb) |
|---|
| .. | .. |
|---|
| 1402 | 1362 | return 0; |
|---|
| 1403 | 1363 | } |
|---|
| 1404 | 1364 | |
|---|
| 1405 | | -static int bb_buf_prepare(struct videobuf_queue *q, |
|---|
| 1406 | | - struct videobuf_buffer *vb, enum v4l2_field field) |
|---|
| 1365 | +static void buffer_queue(struct vb2_buffer *vb) |
|---|
| 1407 | 1366 | { |
|---|
| 1408 | | - struct cx231xx_fh *fh = q->priv_data; |
|---|
| 1409 | 1367 | struct cx231xx_buffer *buf = |
|---|
| 1410 | | - container_of(vb, struct cx231xx_buffer, vb); |
|---|
| 1411 | | - struct cx231xx *dev = fh->dev; |
|---|
| 1412 | | - int rc = 0, urb_init = 0; |
|---|
| 1413 | | - int size = fh->dev->ts1.ts_packet_size * fh->dev->ts1.ts_packet_count; |
|---|
| 1368 | + container_of(vb, struct cx231xx_buffer, vb.vb2_buf); |
|---|
| 1369 | + struct cx231xx *dev = vb2_get_drv_priv(vb->vb2_queue); |
|---|
| 1370 | + struct cx231xx_dmaqueue *vidq = &dev->video_mode.vidq; |
|---|
| 1371 | + unsigned long flags; |
|---|
| 1414 | 1372 | |
|---|
| 1415 | | - if (0 != buf->vb.baddr && buf->vb.bsize < size) |
|---|
| 1416 | | - return -EINVAL; |
|---|
| 1417 | | - buf->vb.width = fh->dev->ts1.ts_packet_size; |
|---|
| 1418 | | - buf->vb.height = fh->dev->ts1.ts_packet_count; |
|---|
| 1419 | | - buf->vb.size = size; |
|---|
| 1420 | | - buf->vb.field = field; |
|---|
| 1373 | + spin_lock_irqsave(&dev->video_mode.slock, flags); |
|---|
| 1374 | + list_add_tail(&buf->list, &vidq->active); |
|---|
| 1375 | + spin_unlock_irqrestore(&dev->video_mode.slock, flags); |
|---|
| 1376 | +} |
|---|
| 1421 | 1377 | |
|---|
| 1422 | | - if (VIDEOBUF_NEEDS_INIT == buf->vb.state) { |
|---|
| 1423 | | - rc = videobuf_iolock(q, &buf->vb, NULL); |
|---|
| 1424 | | - if (rc < 0) |
|---|
| 1425 | | - goto fail; |
|---|
| 1378 | +static void return_all_buffers(struct cx231xx *dev, |
|---|
| 1379 | + enum vb2_buffer_state state) |
|---|
| 1380 | +{ |
|---|
| 1381 | + struct cx231xx_dmaqueue *vidq = &dev->video_mode.vidq; |
|---|
| 1382 | + struct cx231xx_buffer *buf, *node; |
|---|
| 1383 | + unsigned long flags; |
|---|
| 1384 | + |
|---|
| 1385 | + spin_lock_irqsave(&dev->video_mode.slock, flags); |
|---|
| 1386 | + list_for_each_entry_safe(buf, node, &vidq->active, list) { |
|---|
| 1387 | + vb2_buffer_done(&buf->vb.vb2_buf, state); |
|---|
| 1388 | + list_del(&buf->list); |
|---|
| 1426 | 1389 | } |
|---|
| 1390 | + spin_unlock_irqrestore(&dev->video_mode.slock, flags); |
|---|
| 1391 | +} |
|---|
| 1427 | 1392 | |
|---|
| 1428 | | - if (dev->USE_ISO) { |
|---|
| 1429 | | - if (!dev->video_mode.isoc_ctl.num_bufs) |
|---|
| 1430 | | - urb_init = 1; |
|---|
| 1431 | | - } else { |
|---|
| 1432 | | - if (!dev->video_mode.bulk_ctl.num_bufs) |
|---|
| 1433 | | - urb_init = 1; |
|---|
| 1434 | | - } |
|---|
| 1435 | | - dev_dbg(dev->dev, |
|---|
| 1436 | | - "urb_init=%d dev->video_mode.max_pkt_size=%d\n", |
|---|
| 1437 | | - urb_init, dev->video_mode.max_pkt_size); |
|---|
| 1393 | +static int start_streaming(struct vb2_queue *vq, unsigned int count) |
|---|
| 1394 | +{ |
|---|
| 1395 | + struct cx231xx *dev = vb2_get_drv_priv(vq); |
|---|
| 1396 | + struct cx231xx_dmaqueue *vidq = &dev->video_mode.vidq; |
|---|
| 1397 | + int ret = 0; |
|---|
| 1398 | + |
|---|
| 1399 | + vidq->sequence = 0; |
|---|
| 1438 | 1400 | dev->mode_tv = 1; |
|---|
| 1439 | 1401 | |
|---|
| 1440 | | - if (urb_init) { |
|---|
| 1441 | | - rc = cx231xx_set_mode(dev, CX231XX_DIGITAL_MODE); |
|---|
| 1442 | | - rc = cx231xx_unmute_audio(dev); |
|---|
| 1443 | | - if (dev->USE_ISO) { |
|---|
| 1444 | | - cx231xx_set_alt_setting(dev, INDEX_TS1, 4); |
|---|
| 1445 | | - rc = cx231xx_init_isoc(dev, mpeglines, |
|---|
| 1446 | | - mpegbufs, |
|---|
| 1447 | | - dev->ts1_mode.max_pkt_size, |
|---|
| 1448 | | - cx231xx_isoc_copy); |
|---|
| 1449 | | - } else { |
|---|
| 1450 | | - cx231xx_set_alt_setting(dev, INDEX_TS1, 0); |
|---|
| 1451 | | - rc = cx231xx_init_bulk(dev, mpeglines, |
|---|
| 1452 | | - mpegbufs, |
|---|
| 1453 | | - dev->ts1_mode.max_pkt_size, |
|---|
| 1454 | | - cx231xx_bulk_copy); |
|---|
| 1455 | | - } |
|---|
| 1456 | | - if (rc < 0) |
|---|
| 1457 | | - goto fail; |
|---|
| 1458 | | - } |
|---|
| 1402 | + cx231xx_set_alt_setting(dev, INDEX_VANC, 1); |
|---|
| 1403 | + cx231xx_set_gpio_value(dev, 2, 0); |
|---|
| 1459 | 1404 | |
|---|
| 1460 | | - buf->vb.state = VIDEOBUF_PREPARED; |
|---|
| 1461 | | - return 0; |
|---|
| 1405 | + cx231xx_initialize_codec(dev); |
|---|
| 1462 | 1406 | |
|---|
| 1463 | | -fail: |
|---|
| 1464 | | - free_buffer(q, buf); |
|---|
| 1465 | | - return rc; |
|---|
| 1407 | + cx231xx_start_TS1(dev); |
|---|
| 1408 | + |
|---|
| 1409 | + cx231xx_set_alt_setting(dev, INDEX_TS1, 0); |
|---|
| 1410 | + cx231xx_set_mode(dev, CX231XX_DIGITAL_MODE); |
|---|
| 1411 | + if (dev->USE_ISO) |
|---|
| 1412 | + ret = cx231xx_init_isoc(dev, CX231XX_NUM_PACKETS, |
|---|
| 1413 | + CX231XX_NUM_BUFS, |
|---|
| 1414 | + dev->ts1_mode.max_pkt_size, |
|---|
| 1415 | + cx231xx_isoc_copy); |
|---|
| 1416 | + else |
|---|
| 1417 | + ret = cx231xx_init_bulk(dev, 320, 5, |
|---|
| 1418 | + dev->ts1_mode.max_pkt_size, |
|---|
| 1419 | + cx231xx_bulk_copy); |
|---|
| 1420 | + if (ret) |
|---|
| 1421 | + return_all_buffers(dev, VB2_BUF_STATE_QUEUED); |
|---|
| 1422 | + |
|---|
| 1423 | + call_all(dev, video, s_stream, 1); |
|---|
| 1424 | + return ret; |
|---|
| 1466 | 1425 | } |
|---|
| 1467 | 1426 | |
|---|
| 1468 | | -static void bb_buf_queue(struct videobuf_queue *q, |
|---|
| 1469 | | - struct videobuf_buffer *vb) |
|---|
| 1427 | +static void stop_streaming(struct vb2_queue *vq) |
|---|
| 1470 | 1428 | { |
|---|
| 1471 | | - struct cx231xx_fh *fh = q->priv_data; |
|---|
| 1429 | + struct cx231xx *dev = vb2_get_drv_priv(vq); |
|---|
| 1430 | + unsigned long flags; |
|---|
| 1472 | 1431 | |
|---|
| 1473 | | - struct cx231xx_buffer *buf = |
|---|
| 1474 | | - container_of(vb, struct cx231xx_buffer, vb); |
|---|
| 1475 | | - struct cx231xx *dev = fh->dev; |
|---|
| 1476 | | - struct cx231xx_dmaqueue *vidq = &dev->video_mode.vidq; |
|---|
| 1432 | + call_all(dev, video, s_stream, 0); |
|---|
| 1477 | 1433 | |
|---|
| 1478 | | - buf->vb.state = VIDEOBUF_QUEUED; |
|---|
| 1479 | | - list_add_tail(&buf->vb.queue, &vidq->active); |
|---|
| 1434 | + cx231xx_stop_TS1(dev); |
|---|
| 1480 | 1435 | |
|---|
| 1436 | + /* do this before setting alternate! */ |
|---|
| 1437 | + if (dev->USE_ISO) |
|---|
| 1438 | + cx231xx_uninit_isoc(dev); |
|---|
| 1439 | + else |
|---|
| 1440 | + cx231xx_uninit_bulk(dev); |
|---|
| 1441 | + cx231xx_set_mode(dev, CX231XX_SUSPEND); |
|---|
| 1442 | + |
|---|
| 1443 | + cx231xx_api_cmd(dev, CX2341X_ENC_STOP_CAPTURE, 3, 0, |
|---|
| 1444 | + CX231xx_END_NOW, CX231xx_MPEG_CAPTURE, |
|---|
| 1445 | + CX231xx_RAW_BITS_NONE); |
|---|
| 1446 | + |
|---|
| 1447 | + spin_lock_irqsave(&dev->video_mode.slock, flags); |
|---|
| 1448 | + if (dev->USE_ISO) |
|---|
| 1449 | + dev->video_mode.isoc_ctl.buf = NULL; |
|---|
| 1450 | + else |
|---|
| 1451 | + dev->video_mode.bulk_ctl.buf = NULL; |
|---|
| 1452 | + spin_unlock_irqrestore(&dev->video_mode.slock, flags); |
|---|
| 1453 | + return_all_buffers(dev, VB2_BUF_STATE_ERROR); |
|---|
| 1481 | 1454 | } |
|---|
| 1482 | 1455 | |
|---|
| 1483 | | -static void bb_buf_release(struct videobuf_queue *q, |
|---|
| 1484 | | - struct videobuf_buffer *vb) |
|---|
| 1485 | | -{ |
|---|
| 1486 | | - struct cx231xx_buffer *buf = |
|---|
| 1487 | | - container_of(vb, struct cx231xx_buffer, vb); |
|---|
| 1488 | | - /*struct cx231xx_fh *fh = q->priv_data;*/ |
|---|
| 1489 | | - /*struct cx231xx *dev = (struct cx231xx *)fh->dev;*/ |
|---|
| 1490 | | - |
|---|
| 1491 | | - free_buffer(q, buf); |
|---|
| 1492 | | -} |
|---|
| 1493 | | - |
|---|
| 1494 | | -static const struct videobuf_queue_ops cx231xx_qops = { |
|---|
| 1495 | | - .buf_setup = bb_buf_setup, |
|---|
| 1496 | | - .buf_prepare = bb_buf_prepare, |
|---|
| 1497 | | - .buf_queue = bb_buf_queue, |
|---|
| 1498 | | - .buf_release = bb_buf_release, |
|---|
| 1456 | +static struct vb2_ops cx231xx_video_qops = { |
|---|
| 1457 | + .queue_setup = queue_setup, |
|---|
| 1458 | + .buf_queue = buffer_queue, |
|---|
| 1459 | + .start_streaming = start_streaming, |
|---|
| 1460 | + .stop_streaming = stop_streaming, |
|---|
| 1461 | + .wait_prepare = vb2_ops_wait_prepare, |
|---|
| 1462 | + .wait_finish = vb2_ops_wait_finish, |
|---|
| 1499 | 1463 | }; |
|---|
| 1500 | 1464 | |
|---|
| 1501 | 1465 | /* ------------------------------------------------------------------ */ |
|---|
| 1502 | 1466 | |
|---|
| 1503 | | -static int vidioc_cropcap(struct file *file, void *priv, |
|---|
| 1504 | | - struct v4l2_cropcap *cc) |
|---|
| 1467 | +static int vidioc_g_pixelaspect(struct file *file, void *priv, |
|---|
| 1468 | + int type, struct v4l2_fract *f) |
|---|
| 1505 | 1469 | { |
|---|
| 1506 | | - struct cx231xx_fh *fh = priv; |
|---|
| 1507 | | - struct cx231xx *dev = fh->dev; |
|---|
| 1470 | + struct cx231xx *dev = video_drvdata(file); |
|---|
| 1508 | 1471 | bool is_50hz = dev->encodernorm.id & V4L2_STD_625_50; |
|---|
| 1509 | 1472 | |
|---|
| 1510 | | - if (cc->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
|---|
| 1473 | + if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
|---|
| 1511 | 1474 | return -EINVAL; |
|---|
| 1512 | 1475 | |
|---|
| 1513 | | - cc->bounds.left = 0; |
|---|
| 1514 | | - cc->bounds.top = 0; |
|---|
| 1515 | | - cc->bounds.width = dev->ts1.width; |
|---|
| 1516 | | - cc->bounds.height = dev->ts1.height; |
|---|
| 1517 | | - cc->defrect = cc->bounds; |
|---|
| 1518 | | - cc->pixelaspect.numerator = is_50hz ? 54 : 11; |
|---|
| 1519 | | - cc->pixelaspect.denominator = is_50hz ? 59 : 10; |
|---|
| 1476 | + f->numerator = is_50hz ? 54 : 11; |
|---|
| 1477 | + f->denominator = is_50hz ? 59 : 10; |
|---|
| 1520 | 1478 | |
|---|
| 1479 | + return 0; |
|---|
| 1480 | +} |
|---|
| 1481 | + |
|---|
| 1482 | +static int vidioc_g_selection(struct file *file, void *priv, |
|---|
| 1483 | + struct v4l2_selection *s) |
|---|
| 1484 | +{ |
|---|
| 1485 | + struct cx231xx *dev = video_drvdata(file); |
|---|
| 1486 | + |
|---|
| 1487 | + if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
|---|
| 1488 | + return -EINVAL; |
|---|
| 1489 | + |
|---|
| 1490 | + switch (s->target) { |
|---|
| 1491 | + case V4L2_SEL_TGT_CROP_BOUNDS: |
|---|
| 1492 | + case V4L2_SEL_TGT_CROP_DEFAULT: |
|---|
| 1493 | + s->r.left = 0; |
|---|
| 1494 | + s->r.top = 0; |
|---|
| 1495 | + s->r.width = dev->ts1.width; |
|---|
| 1496 | + s->r.height = dev->ts1.height; |
|---|
| 1497 | + break; |
|---|
| 1498 | + default: |
|---|
| 1499 | + return -EINVAL; |
|---|
| 1500 | + } |
|---|
| 1521 | 1501 | return 0; |
|---|
| 1522 | 1502 | } |
|---|
| 1523 | 1503 | |
|---|
| 1524 | 1504 | static int vidioc_g_std(struct file *file, void *fh0, v4l2_std_id *norm) |
|---|
| 1525 | 1505 | { |
|---|
| 1526 | | - struct cx231xx_fh *fh = file->private_data; |
|---|
| 1527 | | - struct cx231xx *dev = fh->dev; |
|---|
| 1506 | + struct cx231xx *dev = video_drvdata(file); |
|---|
| 1528 | 1507 | |
|---|
| 1529 | 1508 | *norm = dev->encodernorm.id; |
|---|
| 1530 | 1509 | return 0; |
|---|
| .. | .. |
|---|
| 1532 | 1511 | |
|---|
| 1533 | 1512 | static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id id) |
|---|
| 1534 | 1513 | { |
|---|
| 1535 | | - struct cx231xx_fh *fh = file->private_data; |
|---|
| 1536 | | - struct cx231xx *dev = fh->dev; |
|---|
| 1514 | + struct cx231xx *dev = video_drvdata(file); |
|---|
| 1537 | 1515 | unsigned int i; |
|---|
| 1538 | 1516 | |
|---|
| 1539 | 1517 | for (i = 0; i < ARRAY_SIZE(cx231xx_tvnorms); i++) |
|---|
| .. | .. |
|---|
| 1565 | 1543 | static int vidioc_s_ctrl(struct file *file, void *priv, |
|---|
| 1566 | 1544 | struct v4l2_control *ctl) |
|---|
| 1567 | 1545 | { |
|---|
| 1568 | | - struct cx231xx_fh *fh = file->private_data; |
|---|
| 1569 | | - struct cx231xx *dev = fh->dev; |
|---|
| 1546 | + struct cx231xx *dev = video_drvdata(file); |
|---|
| 1570 | 1547 | struct v4l2_subdev *sd; |
|---|
| 1571 | 1548 | |
|---|
| 1572 | 1549 | dprintk(3, "enter vidioc_s_ctrl()\n"); |
|---|
| .. | .. |
|---|
| 1583 | 1560 | if (f->index != 0) |
|---|
| 1584 | 1561 | return -EINVAL; |
|---|
| 1585 | 1562 | |
|---|
| 1586 | | - strlcpy(f->description, "MPEG", sizeof(f->description)); |
|---|
| 1587 | 1563 | f->pixelformat = V4L2_PIX_FMT_MPEG; |
|---|
| 1588 | 1564 | |
|---|
| 1589 | 1565 | return 0; |
|---|
| .. | .. |
|---|
| 1592 | 1568 | static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, |
|---|
| 1593 | 1569 | struct v4l2_format *f) |
|---|
| 1594 | 1570 | { |
|---|
| 1595 | | - struct cx231xx_fh *fh = file->private_data; |
|---|
| 1596 | | - struct cx231xx *dev = fh->dev; |
|---|
| 1571 | + struct cx231xx *dev = video_drvdata(file); |
|---|
| 1597 | 1572 | |
|---|
| 1598 | 1573 | dprintk(3, "enter vidioc_g_fmt_vid_cap()\n"); |
|---|
| 1599 | 1574 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; |
|---|
| .. | .. |
|---|
| 1612 | 1587 | static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, |
|---|
| 1613 | 1588 | struct v4l2_format *f) |
|---|
| 1614 | 1589 | { |
|---|
| 1615 | | - struct cx231xx_fh *fh = file->private_data; |
|---|
| 1616 | | - struct cx231xx *dev = fh->dev; |
|---|
| 1590 | + struct cx231xx *dev = video_drvdata(file); |
|---|
| 1617 | 1591 | |
|---|
| 1618 | 1592 | dprintk(3, "enter vidioc_try_fmt_vid_cap()\n"); |
|---|
| 1619 | 1593 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; |
|---|
| .. | .. |
|---|
| 1627 | 1601 | return 0; |
|---|
| 1628 | 1602 | } |
|---|
| 1629 | 1603 | |
|---|
| 1630 | | -static int vidioc_reqbufs(struct file *file, void *priv, |
|---|
| 1631 | | - struct v4l2_requestbuffers *p) |
|---|
| 1632 | | -{ |
|---|
| 1633 | | - struct cx231xx_fh *fh = file->private_data; |
|---|
| 1634 | | - |
|---|
| 1635 | | - return videobuf_reqbufs(&fh->vidq, p); |
|---|
| 1636 | | -} |
|---|
| 1637 | | - |
|---|
| 1638 | | -static int vidioc_querybuf(struct file *file, void *priv, |
|---|
| 1639 | | - struct v4l2_buffer *p) |
|---|
| 1640 | | -{ |
|---|
| 1641 | | - struct cx231xx_fh *fh = file->private_data; |
|---|
| 1642 | | - |
|---|
| 1643 | | - return videobuf_querybuf(&fh->vidq, p); |
|---|
| 1644 | | -} |
|---|
| 1645 | | - |
|---|
| 1646 | | -static int vidioc_qbuf(struct file *file, void *priv, |
|---|
| 1647 | | - struct v4l2_buffer *p) |
|---|
| 1648 | | -{ |
|---|
| 1649 | | - struct cx231xx_fh *fh = file->private_data; |
|---|
| 1650 | | - |
|---|
| 1651 | | - return videobuf_qbuf(&fh->vidq, p); |
|---|
| 1652 | | -} |
|---|
| 1653 | | - |
|---|
| 1654 | | -static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *b) |
|---|
| 1655 | | -{ |
|---|
| 1656 | | - struct cx231xx_fh *fh = priv; |
|---|
| 1657 | | - |
|---|
| 1658 | | - return videobuf_dqbuf(&fh->vidq, b, file->f_flags & O_NONBLOCK); |
|---|
| 1659 | | -} |
|---|
| 1660 | | - |
|---|
| 1661 | | - |
|---|
| 1662 | | -static int vidioc_streamon(struct file *file, void *priv, |
|---|
| 1663 | | - enum v4l2_buf_type i) |
|---|
| 1664 | | -{ |
|---|
| 1665 | | - struct cx231xx_fh *fh = file->private_data; |
|---|
| 1666 | | - struct cx231xx *dev = fh->dev; |
|---|
| 1667 | | - |
|---|
| 1668 | | - dprintk(3, "enter vidioc_streamon()\n"); |
|---|
| 1669 | | - cx231xx_set_alt_setting(dev, INDEX_TS1, 0); |
|---|
| 1670 | | - cx231xx_set_mode(dev, CX231XX_DIGITAL_MODE); |
|---|
| 1671 | | - if (dev->USE_ISO) |
|---|
| 1672 | | - cx231xx_init_isoc(dev, CX231XX_NUM_PACKETS, |
|---|
| 1673 | | - CX231XX_NUM_BUFS, |
|---|
| 1674 | | - dev->video_mode.max_pkt_size, |
|---|
| 1675 | | - cx231xx_isoc_copy); |
|---|
| 1676 | | - else { |
|---|
| 1677 | | - cx231xx_init_bulk(dev, 320, |
|---|
| 1678 | | - 5, |
|---|
| 1679 | | - dev->ts1_mode.max_pkt_size, |
|---|
| 1680 | | - cx231xx_bulk_copy); |
|---|
| 1681 | | - } |
|---|
| 1682 | | - dprintk(3, "exit vidioc_streamon()\n"); |
|---|
| 1683 | | - return videobuf_streamon(&fh->vidq); |
|---|
| 1684 | | -} |
|---|
| 1685 | | - |
|---|
| 1686 | | -static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) |
|---|
| 1687 | | -{ |
|---|
| 1688 | | - struct cx231xx_fh *fh = file->private_data; |
|---|
| 1689 | | - |
|---|
| 1690 | | - return videobuf_streamoff(&fh->vidq); |
|---|
| 1691 | | -} |
|---|
| 1692 | | - |
|---|
| 1693 | 1604 | static int vidioc_log_status(struct file *file, void *priv) |
|---|
| 1694 | 1605 | { |
|---|
| 1695 | | - struct cx231xx_fh *fh = priv; |
|---|
| 1696 | | - struct cx231xx *dev = fh->dev; |
|---|
| 1606 | + struct cx231xx *dev = video_drvdata(file); |
|---|
| 1697 | 1607 | |
|---|
| 1698 | 1608 | call_all(dev, core, log_status); |
|---|
| 1699 | 1609 | return v4l2_ctrl_log_status(file, priv); |
|---|
| 1700 | 1610 | } |
|---|
| 1701 | 1611 | |
|---|
| 1702 | | -static int mpeg_open(struct file *file) |
|---|
| 1703 | | -{ |
|---|
| 1704 | | - struct video_device *vdev = video_devdata(file); |
|---|
| 1705 | | - struct cx231xx *dev = video_drvdata(file); |
|---|
| 1706 | | - struct cx231xx_fh *fh; |
|---|
| 1707 | | - |
|---|
| 1708 | | - dprintk(2, "%s()\n", __func__); |
|---|
| 1709 | | - |
|---|
| 1710 | | - if (mutex_lock_interruptible(&dev->lock)) |
|---|
| 1711 | | - return -ERESTARTSYS; |
|---|
| 1712 | | - |
|---|
| 1713 | | - /* allocate + initialize per filehandle data */ |
|---|
| 1714 | | - fh = kzalloc(sizeof(*fh), GFP_KERNEL); |
|---|
| 1715 | | - if (NULL == fh) { |
|---|
| 1716 | | - mutex_unlock(&dev->lock); |
|---|
| 1717 | | - return -ENOMEM; |
|---|
| 1718 | | - } |
|---|
| 1719 | | - |
|---|
| 1720 | | - file->private_data = fh; |
|---|
| 1721 | | - v4l2_fh_init(&fh->fh, vdev); |
|---|
| 1722 | | - fh->dev = dev; |
|---|
| 1723 | | - |
|---|
| 1724 | | - |
|---|
| 1725 | | - videobuf_queue_vmalloc_init(&fh->vidq, &cx231xx_qops, |
|---|
| 1726 | | - NULL, &dev->video_mode.slock, |
|---|
| 1727 | | - V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_INTERLACED, |
|---|
| 1728 | | - sizeof(struct cx231xx_buffer), fh, &dev->lock); |
|---|
| 1729 | | -/* |
|---|
| 1730 | | - videobuf_queue_sg_init(&fh->vidq, &cx231xx_qops, |
|---|
| 1731 | | - dev->dev, &dev->ts1.slock, |
|---|
| 1732 | | - V4L2_BUF_TYPE_VIDEO_CAPTURE, |
|---|
| 1733 | | - V4L2_FIELD_INTERLACED, |
|---|
| 1734 | | - sizeof(struct cx231xx_buffer), |
|---|
| 1735 | | - fh, &dev->lock); |
|---|
| 1736 | | -*/ |
|---|
| 1737 | | - |
|---|
| 1738 | | - cx231xx_set_alt_setting(dev, INDEX_VANC, 1); |
|---|
| 1739 | | - cx231xx_set_gpio_value(dev, 2, 0); |
|---|
| 1740 | | - |
|---|
| 1741 | | - cx231xx_initialize_codec(dev); |
|---|
| 1742 | | - |
|---|
| 1743 | | - mutex_unlock(&dev->lock); |
|---|
| 1744 | | - v4l2_fh_add(&fh->fh); |
|---|
| 1745 | | - cx231xx_start_TS1(dev); |
|---|
| 1746 | | - |
|---|
| 1747 | | - return 0; |
|---|
| 1748 | | -} |
|---|
| 1749 | | - |
|---|
| 1750 | | -static int mpeg_release(struct file *file) |
|---|
| 1751 | | -{ |
|---|
| 1752 | | - struct cx231xx_fh *fh = file->private_data; |
|---|
| 1753 | | - struct cx231xx *dev = fh->dev; |
|---|
| 1754 | | - |
|---|
| 1755 | | - dprintk(3, "mpeg_release()! dev=0x%p\n", dev); |
|---|
| 1756 | | - |
|---|
| 1757 | | - mutex_lock(&dev->lock); |
|---|
| 1758 | | - |
|---|
| 1759 | | - cx231xx_stop_TS1(dev); |
|---|
| 1760 | | - |
|---|
| 1761 | | - /* do this before setting alternate! */ |
|---|
| 1762 | | - if (dev->USE_ISO) |
|---|
| 1763 | | - cx231xx_uninit_isoc(dev); |
|---|
| 1764 | | - else |
|---|
| 1765 | | - cx231xx_uninit_bulk(dev); |
|---|
| 1766 | | - cx231xx_set_mode(dev, CX231XX_SUSPEND); |
|---|
| 1767 | | - |
|---|
| 1768 | | - cx231xx_api_cmd(fh->dev, CX2341X_ENC_STOP_CAPTURE, 3, 0, |
|---|
| 1769 | | - CX231xx_END_NOW, CX231xx_MPEG_CAPTURE, |
|---|
| 1770 | | - CX231xx_RAW_BITS_NONE); |
|---|
| 1771 | | - |
|---|
| 1772 | | - /* FIXME: Review this crap */ |
|---|
| 1773 | | - /* Shut device down on last close */ |
|---|
| 1774 | | - if (atomic_cmpxchg(&fh->v4l_reading, 1, 0) == 1) { |
|---|
| 1775 | | - if (atomic_dec_return(&dev->v4l_reader_count) == 0) { |
|---|
| 1776 | | - /* stop mpeg capture */ |
|---|
| 1777 | | - |
|---|
| 1778 | | - msleep(500); |
|---|
| 1779 | | - cx231xx_417_check_encoder(dev); |
|---|
| 1780 | | - |
|---|
| 1781 | | - } |
|---|
| 1782 | | - } |
|---|
| 1783 | | - |
|---|
| 1784 | | - if (fh->vidq.streaming) |
|---|
| 1785 | | - videobuf_streamoff(&fh->vidq); |
|---|
| 1786 | | - if (fh->vidq.reading) |
|---|
| 1787 | | - videobuf_read_stop(&fh->vidq); |
|---|
| 1788 | | - |
|---|
| 1789 | | - videobuf_mmap_free(&fh->vidq); |
|---|
| 1790 | | - v4l2_fh_del(&fh->fh); |
|---|
| 1791 | | - v4l2_fh_exit(&fh->fh); |
|---|
| 1792 | | - kfree(fh); |
|---|
| 1793 | | - mutex_unlock(&dev->lock); |
|---|
| 1794 | | - return 0; |
|---|
| 1795 | | -} |
|---|
| 1796 | | - |
|---|
| 1797 | | -static ssize_t mpeg_read(struct file *file, char __user *data, |
|---|
| 1798 | | - size_t count, loff_t *ppos) |
|---|
| 1799 | | -{ |
|---|
| 1800 | | - struct cx231xx_fh *fh = file->private_data; |
|---|
| 1801 | | - struct cx231xx *dev = fh->dev; |
|---|
| 1802 | | - |
|---|
| 1803 | | - /* Deal w/ A/V decoder * and mpeg encoder sync issues. */ |
|---|
| 1804 | | - /* Start mpeg encoder on first read. */ |
|---|
| 1805 | | - if (atomic_cmpxchg(&fh->v4l_reading, 0, 1) == 0) { |
|---|
| 1806 | | - if (atomic_inc_return(&dev->v4l_reader_count) == 1) { |
|---|
| 1807 | | - if (cx231xx_initialize_codec(dev) < 0) |
|---|
| 1808 | | - return -EINVAL; |
|---|
| 1809 | | - } |
|---|
| 1810 | | - } |
|---|
| 1811 | | - |
|---|
| 1812 | | - return videobuf_read_stream(&fh->vidq, data, count, ppos, 0, |
|---|
| 1813 | | - file->f_flags & O_NONBLOCK); |
|---|
| 1814 | | -} |
|---|
| 1815 | | - |
|---|
| 1816 | | -static __poll_t mpeg_poll(struct file *file, |
|---|
| 1817 | | - struct poll_table_struct *wait) |
|---|
| 1818 | | -{ |
|---|
| 1819 | | - __poll_t req_events = poll_requested_events(wait); |
|---|
| 1820 | | - struct cx231xx_fh *fh = file->private_data; |
|---|
| 1821 | | - struct cx231xx *dev = fh->dev; |
|---|
| 1822 | | - __poll_t res = 0; |
|---|
| 1823 | | - |
|---|
| 1824 | | - if (v4l2_event_pending(&fh->fh)) |
|---|
| 1825 | | - res |= EPOLLPRI; |
|---|
| 1826 | | - else |
|---|
| 1827 | | - poll_wait(file, &fh->fh.wait, wait); |
|---|
| 1828 | | - |
|---|
| 1829 | | - if (!(req_events & (EPOLLIN | EPOLLRDNORM))) |
|---|
| 1830 | | - return res; |
|---|
| 1831 | | - |
|---|
| 1832 | | - mutex_lock(&dev->lock); |
|---|
| 1833 | | - res |= videobuf_poll_stream(file, &fh->vidq, wait); |
|---|
| 1834 | | - mutex_unlock(&dev->lock); |
|---|
| 1835 | | - return res; |
|---|
| 1836 | | -} |
|---|
| 1837 | | - |
|---|
| 1838 | | -static int mpeg_mmap(struct file *file, struct vm_area_struct *vma) |
|---|
| 1839 | | -{ |
|---|
| 1840 | | - struct cx231xx_fh *fh = file->private_data; |
|---|
| 1841 | | - |
|---|
| 1842 | | - dprintk(2, "%s()\n", __func__); |
|---|
| 1843 | | - |
|---|
| 1844 | | - return videobuf_mmap_mapper(&fh->vidq, vma); |
|---|
| 1845 | | -} |
|---|
| 1846 | | - |
|---|
| 1847 | 1612 | static const struct v4l2_file_operations mpeg_fops = { |
|---|
| 1848 | 1613 | .owner = THIS_MODULE, |
|---|
| 1849 | | - .open = mpeg_open, |
|---|
| 1850 | | - .release = mpeg_release, |
|---|
| 1851 | | - .read = mpeg_read, |
|---|
| 1852 | | - .poll = mpeg_poll, |
|---|
| 1853 | | - .mmap = mpeg_mmap, |
|---|
| 1614 | + .open = v4l2_fh_open, |
|---|
| 1615 | + .release = vb2_fop_release, |
|---|
| 1616 | + .read = vb2_fop_read, |
|---|
| 1617 | + .poll = vb2_fop_poll, |
|---|
| 1618 | + .mmap = vb2_fop_mmap, |
|---|
| 1854 | 1619 | .unlocked_ioctl = video_ioctl2, |
|---|
| 1855 | 1620 | }; |
|---|
| 1856 | 1621 | |
|---|
| .. | .. |
|---|
| 1865 | 1630 | .vidioc_g_input = cx231xx_g_input, |
|---|
| 1866 | 1631 | .vidioc_s_input = cx231xx_s_input, |
|---|
| 1867 | 1632 | .vidioc_s_ctrl = vidioc_s_ctrl, |
|---|
| 1868 | | - .vidioc_cropcap = vidioc_cropcap, |
|---|
| 1633 | + .vidioc_g_pixelaspect = vidioc_g_pixelaspect, |
|---|
| 1634 | + .vidioc_g_selection = vidioc_g_selection, |
|---|
| 1869 | 1635 | .vidioc_querycap = cx231xx_querycap, |
|---|
| 1870 | 1636 | .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap, |
|---|
| 1871 | 1637 | .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap, |
|---|
| 1872 | 1638 | .vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap, |
|---|
| 1873 | 1639 | .vidioc_s_fmt_vid_cap = vidioc_try_fmt_vid_cap, |
|---|
| 1874 | | - .vidioc_reqbufs = vidioc_reqbufs, |
|---|
| 1875 | | - .vidioc_querybuf = vidioc_querybuf, |
|---|
| 1876 | | - .vidioc_qbuf = vidioc_qbuf, |
|---|
| 1877 | | - .vidioc_dqbuf = vidioc_dqbuf, |
|---|
| 1878 | | - .vidioc_streamon = vidioc_streamon, |
|---|
| 1879 | | - .vidioc_streamoff = vidioc_streamoff, |
|---|
| 1640 | + .vidioc_reqbufs = vb2_ioctl_reqbufs, |
|---|
| 1641 | + .vidioc_querybuf = vb2_ioctl_querybuf, |
|---|
| 1642 | + .vidioc_qbuf = vb2_ioctl_qbuf, |
|---|
| 1643 | + .vidioc_dqbuf = vb2_ioctl_dqbuf, |
|---|
| 1644 | + .vidioc_streamon = vb2_ioctl_streamon, |
|---|
| 1645 | + .vidioc_streamoff = vb2_ioctl_streamoff, |
|---|
| 1880 | 1646 | .vidioc_log_status = vidioc_log_status, |
|---|
| 1881 | 1647 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
|---|
| 1882 | 1648 | .vidioc_g_register = cx231xx_g_register, |
|---|
| .. | .. |
|---|
| 1968 | 1734 | int cx231xx_417_register(struct cx231xx *dev) |
|---|
| 1969 | 1735 | { |
|---|
| 1970 | 1736 | /* FIXME: Port1 hardcoded here */ |
|---|
| 1971 | | - int err = -ENODEV; |
|---|
| 1737 | + int err; |
|---|
| 1972 | 1738 | struct cx231xx_tsport *tsport = &dev->ts1; |
|---|
| 1739 | + struct vb2_queue *q; |
|---|
| 1973 | 1740 | |
|---|
| 1974 | 1741 | dprintk(1, "%s()\n", __func__); |
|---|
| 1975 | 1742 | |
|---|
| .. | .. |
|---|
| 1992 | 1759 | dev->mpeg_ctrl_handler.ops = &cx231xx_ops; |
|---|
| 1993 | 1760 | if (dev->sd_cx25840) |
|---|
| 1994 | 1761 | v4l2_ctrl_add_handler(&dev->mpeg_ctrl_handler.hdl, |
|---|
| 1995 | | - dev->sd_cx25840->ctrl_handler, NULL); |
|---|
| 1762 | + dev->sd_cx25840->ctrl_handler, NULL, false); |
|---|
| 1996 | 1763 | if (dev->mpeg_ctrl_handler.hdl.error) { |
|---|
| 1997 | 1764 | err = dev->mpeg_ctrl_handler.hdl.error; |
|---|
| 1998 | 1765 | dprintk(3, "%s: can't add cx25840 controls\n", dev->name); |
|---|
| .. | .. |
|---|
| 2007 | 1774 | /* Allocate and initialize V4L video device */ |
|---|
| 2008 | 1775 | cx231xx_video_dev_init(dev, dev->udev, |
|---|
| 2009 | 1776 | &dev->v4l_device, &cx231xx_mpeg_template, "mpeg"); |
|---|
| 1777 | + q = &dev->mpegq; |
|---|
| 1778 | + q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
|---|
| 1779 | + q->io_modes = VB2_USERPTR | VB2_MMAP | VB2_DMABUF | VB2_READ; |
|---|
| 1780 | + q->drv_priv = dev; |
|---|
| 1781 | + q->buf_struct_size = sizeof(struct cx231xx_buffer); |
|---|
| 1782 | + q->ops = &cx231xx_video_qops; |
|---|
| 1783 | + q->mem_ops = &vb2_vmalloc_memops; |
|---|
| 1784 | + q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; |
|---|
| 1785 | + q->min_buffers_needed = 1; |
|---|
| 1786 | + q->lock = &dev->lock; |
|---|
| 1787 | + err = vb2_queue_init(q); |
|---|
| 1788 | + if (err) |
|---|
| 1789 | + return err; |
|---|
| 1790 | + dev->v4l_device.queue = q; |
|---|
| 1791 | + |
|---|
| 2010 | 1792 | err = video_register_device(&dev->v4l_device, |
|---|
| 2011 | | - VFL_TYPE_GRABBER, -1); |
|---|
| 1793 | + VFL_TYPE_VIDEO, -1); |
|---|
| 2012 | 1794 | if (err < 0) { |
|---|
| 2013 | 1795 | dprintk(3, "%s: can't register mpeg device\n", dev->name); |
|---|
| 2014 | 1796 | v4l2_ctrl_handler_free(&dev->mpeg_ctrl_handler.hdl); |
|---|