.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * |
---|
3 | 4 | * device driver for philips saa7134 based TV cards |
---|
4 | 5 | * driver core |
---|
5 | 6 | * |
---|
6 | 7 | * (c) 2001-03 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs] |
---|
7 | | - * |
---|
8 | | - * This program is free software; you can redistribute it and/or modify |
---|
9 | | - * it under the terms of the GNU General Public License as published by |
---|
10 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
11 | | - * (at your option) any later version. |
---|
12 | | - * |
---|
13 | | - * This program is distributed in the hope that it will be useful, |
---|
14 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | | - * GNU General Public License for more details. |
---|
17 | 8 | */ |
---|
18 | 9 | |
---|
19 | 10 | #include "saa7134.h" |
---|
.. | .. |
---|
252 | 243 | |
---|
253 | 244 | ptr = pt->cpu + startpage; |
---|
254 | 245 | for (i = 0; i < length; i++, list = sg_next(list)) { |
---|
255 | | - for (p = 0; p * 4096 < list->length; p++, ptr++) |
---|
| 246 | + for (p = 0; p * 4096 < sg_dma_len(list); p++, ptr++) |
---|
256 | 247 | *ptr = cpu_to_le32(sg_dma_address(list) + |
---|
257 | 248 | list->offset + p * 4096); |
---|
258 | 249 | } |
---|
.. | .. |
---|
368 | 359 | struct saa7134_buf *tmp; |
---|
369 | 360 | |
---|
370 | 361 | spin_lock_irqsave(&dev->slock, flags); |
---|
371 | | - if (!list_empty(&q->queue)) { |
---|
372 | | - list_for_each_safe(pos, n, &q->queue) { |
---|
373 | | - tmp = list_entry(pos, struct saa7134_buf, entry); |
---|
374 | | - vb2_buffer_done(&tmp->vb2.vb2_buf, |
---|
375 | | - VB2_BUF_STATE_ERROR); |
---|
376 | | - list_del(pos); |
---|
377 | | - tmp = NULL; |
---|
378 | | - } |
---|
| 362 | + list_for_each_safe(pos, n, &q->queue) { |
---|
| 363 | + tmp = list_entry(pos, struct saa7134_buf, entry); |
---|
| 364 | + vb2_buffer_done(&tmp->vb2.vb2_buf, |
---|
| 365 | + VB2_BUF_STATE_ERROR); |
---|
| 366 | + list_del(pos); |
---|
| 367 | + tmp = NULL; |
---|
379 | 368 | } |
---|
380 | 369 | spin_unlock_irqrestore(&dev->slock, flags); |
---|
381 | 370 | saa7134_buffer_timeout(&q->timeout); /* also calls del_timer(&q->timeout) */ |
---|
.. | .. |
---|
845 | 834 | */ |
---|
846 | 835 | if (!decoder) { |
---|
847 | 836 | dev->demod.name = "saa713x"; |
---|
848 | | - dev->demod_pad[DEMOD_PAD_IF_INPUT].flags = MEDIA_PAD_FL_SINK; |
---|
849 | | - dev->demod_pad[DEMOD_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE; |
---|
850 | | - dev->demod_pad[DEMOD_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE; |
---|
| 837 | + dev->demod_pad[SAA7134_PAD_IF_INPUT].flags = MEDIA_PAD_FL_SINK; |
---|
| 838 | + dev->demod_pad[SAA7134_PAD_IF_INPUT].sig_type = PAD_SIGNAL_ANALOG; |
---|
| 839 | + dev->demod_pad[SAA7134_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE; |
---|
| 840 | + dev->demod_pad[SAA7134_PAD_VID_OUT].sig_type = PAD_SIGNAL_DV; |
---|
851 | 841 | dev->demod.function = MEDIA_ENT_F_ATV_DECODER; |
---|
852 | 842 | |
---|
853 | | - ret = media_entity_pads_init(&dev->demod, DEMOD_NUM_PADS, |
---|
| 843 | + ret = media_entity_pads_init(&dev->demod, SAA7134_NUM_PADS, |
---|
854 | 844 | dev->demod_pad); |
---|
855 | 845 | if (ret < 0) |
---|
856 | 846 | pr_err("failed to initialize demod pad!\n"); |
---|
.. | .. |
---|
973 | 963 | |
---|
974 | 964 | if (dev->video_dev) { |
---|
975 | 965 | if (video_is_registered(dev->video_dev)) |
---|
976 | | - video_unregister_device(dev->video_dev); |
---|
| 966 | + vb2_video_unregister_device(dev->video_dev); |
---|
977 | 967 | else |
---|
978 | 968 | video_device_release(dev->video_dev); |
---|
979 | 969 | dev->video_dev = NULL; |
---|
980 | 970 | } |
---|
981 | 971 | if (dev->vbi_dev) { |
---|
982 | 972 | if (video_is_registered(dev->vbi_dev)) |
---|
983 | | - video_unregister_device(dev->vbi_dev); |
---|
| 973 | + vb2_video_unregister_device(dev->vbi_dev); |
---|
984 | 974 | else |
---|
985 | 975 | video_device_release(dev->vbi_dev); |
---|
986 | 976 | dev->vbi_dev = NULL; |
---|
.. | .. |
---|
1214 | 1204 | dev->video_dev->ctrl_handler = &dev->ctrl_handler; |
---|
1215 | 1205 | dev->video_dev->lock = &dev->lock; |
---|
1216 | 1206 | dev->video_dev->queue = &dev->video_vbq; |
---|
1217 | | - err = video_register_device(dev->video_dev,VFL_TYPE_GRABBER, |
---|
| 1207 | + dev->video_dev->device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING | |
---|
| 1208 | + V4L2_CAP_VIDEO_CAPTURE; |
---|
| 1209 | + if (dev->tuner_type != TUNER_ABSENT && dev->tuner_type != UNSET) |
---|
| 1210 | + dev->video_dev->device_caps |= V4L2_CAP_TUNER; |
---|
| 1211 | + |
---|
| 1212 | + if (saa7134_no_overlay <= 0) |
---|
| 1213 | + dev->video_dev->device_caps |= V4L2_CAP_VIDEO_OVERLAY; |
---|
| 1214 | + |
---|
| 1215 | + err = video_register_device(dev->video_dev,VFL_TYPE_VIDEO, |
---|
1218 | 1216 | video_nr[dev->nr]); |
---|
1219 | 1217 | if (err < 0) { |
---|
1220 | 1218 | pr_info("%s: can't register video device\n", |
---|
.. | .. |
---|
1228 | 1226 | dev->vbi_dev->ctrl_handler = &dev->ctrl_handler; |
---|
1229 | 1227 | dev->vbi_dev->lock = &dev->lock; |
---|
1230 | 1228 | dev->vbi_dev->queue = &dev->vbi_vbq; |
---|
| 1229 | + dev->vbi_dev->device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING | |
---|
| 1230 | + V4L2_CAP_VBI_CAPTURE; |
---|
| 1231 | + if (dev->tuner_type != TUNER_ABSENT && dev->tuner_type != UNSET) |
---|
| 1232 | + dev->vbi_dev->device_caps |= V4L2_CAP_TUNER; |
---|
1231 | 1233 | |
---|
1232 | 1234 | err = video_register_device(dev->vbi_dev,VFL_TYPE_VBI, |
---|
1233 | 1235 | vbi_nr[dev->nr]); |
---|
.. | .. |
---|
1240 | 1242 | dev->radio_dev = vdev_init(dev,&saa7134_radio_template,"radio"); |
---|
1241 | 1243 | dev->radio_dev->ctrl_handler = &dev->radio_ctrl_handler; |
---|
1242 | 1244 | dev->radio_dev->lock = &dev->lock; |
---|
| 1245 | + dev->radio_dev->device_caps = V4L2_CAP_RADIO | V4L2_CAP_TUNER; |
---|
| 1246 | + if (dev->has_rds) |
---|
| 1247 | + dev->radio_dev->device_caps |= V4L2_CAP_RDS_CAPTURE; |
---|
1243 | 1248 | err = video_register_device(dev->radio_dev,VFL_TYPE_RADIO, |
---|
1244 | 1249 | radio_nr[dev->nr]); |
---|
1245 | 1250 | if (err < 0) |
---|
.. | .. |
---|
1363 | 1368 | kfree(dev); |
---|
1364 | 1369 | } |
---|
1365 | 1370 | |
---|
1366 | | -#ifdef CONFIG_PM |
---|
1367 | | - |
---|
1368 | 1371 | /* resends a current buffer in queue after resume */ |
---|
1369 | | -static int saa7134_buffer_requeue(struct saa7134_dev *dev, |
---|
1370 | | - struct saa7134_dmaqueue *q) |
---|
| 1372 | +static int __maybe_unused saa7134_buffer_requeue(struct saa7134_dev *dev, |
---|
| 1373 | + struct saa7134_dmaqueue *q) |
---|
1371 | 1374 | { |
---|
1372 | 1375 | struct saa7134_buf *buf, *next; |
---|
1373 | 1376 | |
---|
.. | .. |
---|
1390 | 1393 | return 0; |
---|
1391 | 1394 | } |
---|
1392 | 1395 | |
---|
1393 | | -static int saa7134_suspend(struct pci_dev *pci_dev , pm_message_t state) |
---|
| 1396 | +static int __maybe_unused saa7134_suspend(struct device *dev_d) |
---|
1394 | 1397 | { |
---|
| 1398 | + struct pci_dev *pci_dev = to_pci_dev(dev_d); |
---|
1395 | 1399 | struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev); |
---|
1396 | 1400 | struct saa7134_dev *dev = container_of(v4l2_dev, struct saa7134_dev, v4l2_dev); |
---|
1397 | 1401 | |
---|
.. | .. |
---|
1418 | 1422 | del_timer(&dev->vbi_q.timeout); |
---|
1419 | 1423 | del_timer(&dev->ts_q.timeout); |
---|
1420 | 1424 | |
---|
1421 | | - if (dev->remote) |
---|
1422 | | - saa7134_ir_stop(dev); |
---|
1423 | | - |
---|
1424 | | - pci_save_state(pci_dev); |
---|
1425 | | - pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state)); |
---|
| 1425 | + if (dev->remote && dev->remote->dev->users) |
---|
| 1426 | + saa7134_ir_close(dev->remote->dev); |
---|
1426 | 1427 | |
---|
1427 | 1428 | return 0; |
---|
1428 | 1429 | } |
---|
1429 | 1430 | |
---|
1430 | | -static int saa7134_resume(struct pci_dev *pci_dev) |
---|
| 1431 | +static int __maybe_unused saa7134_resume(struct device *dev_d) |
---|
1431 | 1432 | { |
---|
1432 | | - struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev); |
---|
| 1433 | + struct v4l2_device *v4l2_dev = dev_get_drvdata(dev_d); |
---|
1433 | 1434 | struct saa7134_dev *dev = container_of(v4l2_dev, struct saa7134_dev, v4l2_dev); |
---|
1434 | 1435 | unsigned long flags; |
---|
1435 | | - |
---|
1436 | | - pci_set_power_state(pci_dev, PCI_D0); |
---|
1437 | | - pci_restore_state(pci_dev); |
---|
1438 | 1436 | |
---|
1439 | 1437 | /* Do things that are done in saa7134_initdev , |
---|
1440 | 1438 | except of initializing memory structures.*/ |
---|
.. | .. |
---|
1446 | 1444 | saa7134_videoport_init(dev); |
---|
1447 | 1445 | if (card_has_mpeg(dev)) |
---|
1448 | 1446 | saa7134_ts_init_hw(dev); |
---|
1449 | | - if (dev->remote) |
---|
1450 | | - saa7134_ir_start(dev); |
---|
| 1447 | + if (dev->remote && dev->remote->dev->users) |
---|
| 1448 | + saa7134_ir_open(dev->remote->dev); |
---|
1451 | 1449 | saa7134_hw_enable1(dev); |
---|
1452 | 1450 | |
---|
1453 | 1451 | msleep(100); |
---|
.. | .. |
---|
1483 | 1481 | |
---|
1484 | 1482 | return 0; |
---|
1485 | 1483 | } |
---|
1486 | | -#endif |
---|
1487 | 1484 | |
---|
1488 | 1485 | /* ----------------------------------------------------------- */ |
---|
1489 | 1486 | |
---|
.. | .. |
---|
1515 | 1512 | |
---|
1516 | 1513 | /* ----------------------------------------------------------- */ |
---|
1517 | 1514 | |
---|
| 1515 | +static SIMPLE_DEV_PM_OPS(saa7134_pm_ops, saa7134_suspend, saa7134_resume); |
---|
| 1516 | + |
---|
1518 | 1517 | static struct pci_driver saa7134_pci_driver = { |
---|
1519 | 1518 | .name = "saa7134", |
---|
1520 | 1519 | .id_table = saa7134_pci_tbl, |
---|
1521 | 1520 | .probe = saa7134_initdev, |
---|
1522 | 1521 | .remove = saa7134_finidev, |
---|
1523 | | -#ifdef CONFIG_PM |
---|
1524 | | - .suspend = saa7134_suspend, |
---|
1525 | | - .resume = saa7134_resume |
---|
1526 | | -#endif |
---|
| 1522 | + .driver.pm = &saa7134_pm_ops, |
---|
1527 | 1523 | }; |
---|
1528 | 1524 | |
---|
1529 | 1525 | static int __init saa7134_init(void) |
---|