| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | ioctl system call |
|---|
| 3 | 4 | Copyright (C) 2003-2004 Kevin Thayer <nufan_wfk at yahoo.com> |
|---|
| 4 | 5 | Copyright (C) 2005-2007 Hans Verkuil <hverkuil@xs4all.nl> |
|---|
| 5 | 6 | |
|---|
| 6 | | - This program is free software; you can redistribute it and/or modify |
|---|
| 7 | | - it under the terms of the GNU General Public License as published by |
|---|
| 8 | | - the Free Software Foundation; either version 2 of the License, or |
|---|
| 9 | | - (at your option) any later version. |
|---|
| 10 | | - |
|---|
| 11 | | - This program is distributed in the hope that it will be useful, |
|---|
| 12 | | - but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | | - GNU General Public License for more details. |
|---|
| 15 | | - |
|---|
| 16 | | - You should have received a copy of the GNU General Public License |
|---|
| 17 | | - along with this program; if not, write to the Free Software |
|---|
| 18 | | - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 19 | 7 | */ |
|---|
| 20 | 8 | |
|---|
| 21 | 9 | #include "ivtv-driver.h" |
|---|
| .. | .. |
|---|
| 36 | 24 | #include <media/tveeprom.h> |
|---|
| 37 | 25 | #include <media/v4l2-event.h> |
|---|
| 38 | 26 | #ifdef CONFIG_VIDEO_IVTV_DEPRECATED_IOCTLS |
|---|
| 27 | +#include <linux/compat.h> |
|---|
| 39 | 28 | #include <linux/dvb/audio.h> |
|---|
| 40 | 29 | #include <linux/dvb/video.h> |
|---|
| 41 | 30 | #endif |
|---|
| .. | .. |
|---|
| 84 | 73 | return 0; |
|---|
| 85 | 74 | } |
|---|
| 86 | 75 | for (i = 0; i < 32; i++) { |
|---|
| 87 | | - if ((1 << i) & set) |
|---|
| 88 | | - return 1 << i; |
|---|
| 76 | + if (BIT(i) & set) |
|---|
| 77 | + return BIT(i); |
|---|
| 89 | 78 | } |
|---|
| 90 | 79 | return 0; |
|---|
| 91 | 80 | } |
|---|
| .. | .. |
|---|
| 454 | 443 | struct ivtv_stream *s = &itv->streams[fh2id(fh)->type]; |
|---|
| 455 | 444 | struct v4l2_window *winfmt = &fmt->fmt.win; |
|---|
| 456 | 445 | |
|---|
| 457 | | - if (!(s->caps & V4L2_CAP_VIDEO_OUTPUT_OVERLAY)) |
|---|
| 446 | + if (!(s->vdev.device_caps & V4L2_CAP_VIDEO_OUTPUT_OVERLAY)) |
|---|
| 458 | 447 | return -EINVAL; |
|---|
| 459 | 448 | if (!itv->osd_video_pbase) |
|---|
| 460 | 449 | return -EINVAL; |
|---|
| .. | .. |
|---|
| 565 | 554 | u32 chromakey = fmt->fmt.win.chromakey; |
|---|
| 566 | 555 | u8 global_alpha = fmt->fmt.win.global_alpha; |
|---|
| 567 | 556 | |
|---|
| 568 | | - if (!(s->caps & V4L2_CAP_VIDEO_OUTPUT_OVERLAY)) |
|---|
| 557 | + if (!(s->vdev.device_caps & V4L2_CAP_VIDEO_OUTPUT_OVERLAY)) |
|---|
| 569 | 558 | return -EINVAL; |
|---|
| 570 | 559 | if (!itv->osd_video_pbase) |
|---|
| 571 | 560 | return -EINVAL; |
|---|
| .. | .. |
|---|
| 745 | 734 | { |
|---|
| 746 | 735 | struct ivtv_open_id *id = fh2id(file->private_data); |
|---|
| 747 | 736 | struct ivtv *itv = id->itv; |
|---|
| 748 | | - struct ivtv_stream *s = &itv->streams[id->type]; |
|---|
| 749 | 737 | |
|---|
| 750 | | - strlcpy(vcap->driver, IVTV_DRIVER_NAME, sizeof(vcap->driver)); |
|---|
| 751 | | - strlcpy(vcap->card, itv->card_name, sizeof(vcap->card)); |
|---|
| 738 | + strscpy(vcap->driver, IVTV_DRIVER_NAME, sizeof(vcap->driver)); |
|---|
| 739 | + strscpy(vcap->card, itv->card_name, sizeof(vcap->card)); |
|---|
| 752 | 740 | snprintf(vcap->bus_info, sizeof(vcap->bus_info), "PCI:%s", pci_name(itv->pdev)); |
|---|
| 753 | 741 | vcap->capabilities = itv->v4l2_cap | V4L2_CAP_DEVICE_CAPS; |
|---|
| 754 | | - vcap->device_caps = s->caps; |
|---|
| 755 | | - if ((s->caps & V4L2_CAP_VIDEO_OUTPUT_OVERLAY) && |
|---|
| 756 | | - !itv->osd_video_pbase) { |
|---|
| 757 | | - vcap->capabilities &= ~V4L2_CAP_VIDEO_OUTPUT_OVERLAY; |
|---|
| 758 | | - vcap->device_caps &= ~V4L2_CAP_VIDEO_OUTPUT_OVERLAY; |
|---|
| 759 | | - } |
|---|
| 760 | 742 | return 0; |
|---|
| 761 | 743 | } |
|---|
| 762 | 744 | |
|---|
| .. | .. |
|---|
| 828 | 810 | return ivtv_get_output(itv, vout->index, vout); |
|---|
| 829 | 811 | } |
|---|
| 830 | 812 | |
|---|
| 831 | | -static int ivtv_cropcap(struct file *file, void *fh, struct v4l2_cropcap *cropcap) |
|---|
| 813 | +static int ivtv_g_pixelaspect(struct file *file, void *fh, |
|---|
| 814 | + int type, struct v4l2_fract *f) |
|---|
| 832 | 815 | { |
|---|
| 833 | 816 | struct ivtv_open_id *id = fh2id(fh); |
|---|
| 834 | 817 | struct ivtv *itv = id->itv; |
|---|
| 835 | 818 | |
|---|
| 836 | | - if (cropcap->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { |
|---|
| 837 | | - cropcap->pixelaspect.numerator = itv->is_50hz ? 54 : 11; |
|---|
| 838 | | - cropcap->pixelaspect.denominator = itv->is_50hz ? 59 : 10; |
|---|
| 839 | | - } else if (cropcap->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { |
|---|
| 840 | | - cropcap->pixelaspect.numerator = itv->is_out_50hz ? 54 : 11; |
|---|
| 841 | | - cropcap->pixelaspect.denominator = itv->is_out_50hz ? 59 : 10; |
|---|
| 819 | + if (type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { |
|---|
| 820 | + f->numerator = itv->is_50hz ? 54 : 11; |
|---|
| 821 | + f->denominator = itv->is_50hz ? 59 : 10; |
|---|
| 822 | + } else if (type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { |
|---|
| 823 | + f->numerator = itv->is_out_50hz ? 54 : 11; |
|---|
| 824 | + f->denominator = itv->is_out_50hz ? 59 : 10; |
|---|
| 842 | 825 | } else { |
|---|
| 843 | 826 | return -EINVAL; |
|---|
| 844 | 827 | } |
|---|
| .. | .. |
|---|
| 937 | 920 | static int ivtv_enum_fmt_vid_cap(struct file *file, void *fh, struct v4l2_fmtdesc *fmt) |
|---|
| 938 | 921 | { |
|---|
| 939 | 922 | static const struct v4l2_fmtdesc hm12 = { |
|---|
| 940 | | - 0, V4L2_BUF_TYPE_VIDEO_CAPTURE, 0, |
|---|
| 941 | | - "HM12 (YUV 4:2:0)", V4L2_PIX_FMT_HM12, |
|---|
| 942 | | - { 0, 0, 0, 0 } |
|---|
| 923 | + .type = V4L2_BUF_TYPE_VIDEO_CAPTURE, |
|---|
| 924 | + .description = "HM12 (YUV 4:2:0)", |
|---|
| 925 | + .pixelformat = V4L2_PIX_FMT_HM12, |
|---|
| 943 | 926 | }; |
|---|
| 944 | 927 | static const struct v4l2_fmtdesc mpeg = { |
|---|
| 945 | | - 0, V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FMT_FLAG_COMPRESSED, |
|---|
| 946 | | - "MPEG", V4L2_PIX_FMT_MPEG, |
|---|
| 947 | | - { 0, 0, 0, 0 } |
|---|
| 928 | + .type = V4L2_BUF_TYPE_VIDEO_CAPTURE, |
|---|
| 929 | + .flags = V4L2_FMT_FLAG_COMPRESSED, |
|---|
| 930 | + .description = "MPEG", |
|---|
| 931 | + .pixelformat = V4L2_PIX_FMT_MPEG, |
|---|
| 948 | 932 | }; |
|---|
| 949 | 933 | struct ivtv *itv = fh2id(fh)->itv; |
|---|
| 950 | 934 | struct ivtv_stream *s = &itv->streams[fh2id(fh)->type]; |
|---|
| .. | .. |
|---|
| 963 | 947 | static int ivtv_enum_fmt_vid_out(struct file *file, void *fh, struct v4l2_fmtdesc *fmt) |
|---|
| 964 | 948 | { |
|---|
| 965 | 949 | static const struct v4l2_fmtdesc hm12 = { |
|---|
| 966 | | - 0, V4L2_BUF_TYPE_VIDEO_OUTPUT, 0, |
|---|
| 967 | | - "HM12 (YUV 4:2:0)", V4L2_PIX_FMT_HM12, |
|---|
| 968 | | - { 0, 0, 0, 0 } |
|---|
| 950 | + .type = V4L2_BUF_TYPE_VIDEO_OUTPUT, |
|---|
| 951 | + .description = "HM12 (YUV 4:2:0)", |
|---|
| 952 | + .pixelformat = V4L2_PIX_FMT_HM12, |
|---|
| 969 | 953 | }; |
|---|
| 970 | 954 | static const struct v4l2_fmtdesc mpeg = { |
|---|
| 971 | | - 0, V4L2_BUF_TYPE_VIDEO_OUTPUT, V4L2_FMT_FLAG_COMPRESSED, |
|---|
| 972 | | - "MPEG", V4L2_PIX_FMT_MPEG, |
|---|
| 973 | | - { 0, 0, 0, 0 } |
|---|
| 955 | + .type = V4L2_BUF_TYPE_VIDEO_OUTPUT, |
|---|
| 956 | + .flags = V4L2_FMT_FLAG_COMPRESSED, |
|---|
| 957 | + .description = "MPEG", |
|---|
| 958 | + .pixelformat = V4L2_PIX_FMT_MPEG, |
|---|
| 974 | 959 | }; |
|---|
| 975 | 960 | struct ivtv *itv = fh2id(fh)->itv; |
|---|
| 976 | 961 | struct ivtv_stream *s = &itv->streams[fh2id(fh)->type]; |
|---|
| .. | .. |
|---|
| 1227 | 1212 | ivtv_call_all(itv, tuner, g_tuner, vt); |
|---|
| 1228 | 1213 | |
|---|
| 1229 | 1214 | if (vt->type == V4L2_TUNER_RADIO) |
|---|
| 1230 | | - strlcpy(vt->name, "ivtv Radio Tuner", sizeof(vt->name)); |
|---|
| 1215 | + strscpy(vt->name, "ivtv Radio Tuner", sizeof(vt->name)); |
|---|
| 1231 | 1216 | else |
|---|
| 1232 | | - strlcpy(vt->name, "ivtv TV Tuner", sizeof(vt->name)); |
|---|
| 1217 | + strscpy(vt->name, "ivtv TV Tuner", sizeof(vt->name)); |
|---|
| 1233 | 1218 | return 0; |
|---|
| 1234 | 1219 | } |
|---|
| 1235 | 1220 | |
|---|
| .. | .. |
|---|
| 1403 | 1388 | 0, |
|---|
| 1404 | 1389 | }; |
|---|
| 1405 | 1390 | |
|---|
| 1406 | | - if (!(s->caps & V4L2_CAP_VIDEO_OUTPUT_OVERLAY)) |
|---|
| 1391 | + if (!(s->vdev.device_caps & V4L2_CAP_VIDEO_OUTPUT_OVERLAY)) |
|---|
| 1407 | 1392 | return -ENOTTY; |
|---|
| 1408 | 1393 | if (!itv->osd_video_pbase) |
|---|
| 1409 | 1394 | return -ENOTTY; |
|---|
| .. | .. |
|---|
| 1470 | 1455 | struct ivtv_stream *s = &itv->streams[fh2id(fh)->type]; |
|---|
| 1471 | 1456 | struct yuv_playback_info *yi = &itv->yuv_info; |
|---|
| 1472 | 1457 | |
|---|
| 1473 | | - if (!(s->caps & V4L2_CAP_VIDEO_OUTPUT_OVERLAY)) |
|---|
| 1458 | + if (!(s->vdev.device_caps & V4L2_CAP_VIDEO_OUTPUT_OVERLAY)) |
|---|
| 1474 | 1459 | return -ENOTTY; |
|---|
| 1475 | 1460 | if (!itv->osd_video_pbase) |
|---|
| 1476 | 1461 | return -ENOTTY; |
|---|
| .. | .. |
|---|
| 1490 | 1475 | struct ivtv *itv = id->itv; |
|---|
| 1491 | 1476 | struct ivtv_stream *s = &itv->streams[fh2id(fh)->type]; |
|---|
| 1492 | 1477 | |
|---|
| 1493 | | - if (!(s->caps & V4L2_CAP_VIDEO_OUTPUT_OVERLAY)) |
|---|
| 1478 | + if (!(s->vdev.device_caps & V4L2_CAP_VIDEO_OUTPUT_OVERLAY)) |
|---|
| 1494 | 1479 | return -ENOTTY; |
|---|
| 1495 | 1480 | if (!itv->osd_video_pbase) |
|---|
| 1496 | 1481 | return -ENOTTY; |
|---|
| .. | .. |
|---|
| 1627 | 1612 | pr_warn_once("warning: the %s ioctl is deprecated. Don't use it, as it will be removed soon\n", |
|---|
| 1628 | 1613 | name); |
|---|
| 1629 | 1614 | } |
|---|
| 1615 | + |
|---|
| 1616 | +#ifdef CONFIG_COMPAT |
|---|
| 1617 | +struct compat_video_event { |
|---|
| 1618 | + __s32 type; |
|---|
| 1619 | + /* unused, make sure to use atomic time for y2038 if it ever gets used */ |
|---|
| 1620 | + compat_long_t timestamp; |
|---|
| 1621 | + union { |
|---|
| 1622 | + video_size_t size; |
|---|
| 1623 | + unsigned int frame_rate; /* in frames per 1000sec */ |
|---|
| 1624 | + unsigned char vsync_field; /* unknown/odd/even/progressive */ |
|---|
| 1625 | + } u; |
|---|
| 1626 | +}; |
|---|
| 1627 | +#define VIDEO_GET_EVENT32 _IOR('o', 28, struct compat_video_event) |
|---|
| 1628 | +#endif |
|---|
| 1629 | + |
|---|
| 1630 | 1630 | #endif |
|---|
| 1631 | 1631 | |
|---|
| 1632 | 1632 | static int ivtv_decoder_ioctls(struct file *filp, unsigned int cmd, void *arg) |
|---|
| .. | .. |
|---|
| 1749 | 1749 | return ivtv_video_command(itv, id, dc, try); |
|---|
| 1750 | 1750 | } |
|---|
| 1751 | 1751 | |
|---|
| 1752 | +#ifdef CONFIG_COMPAT |
|---|
| 1753 | + case VIDEO_GET_EVENT32: |
|---|
| 1754 | +#endif |
|---|
| 1752 | 1755 | case VIDEO_GET_EVENT: { |
|---|
| 1756 | +#ifdef CONFIG_COMPAT |
|---|
| 1757 | + struct compat_video_event *ev32 = arg; |
|---|
| 1758 | +#endif |
|---|
| 1753 | 1759 | struct video_event *ev = arg; |
|---|
| 1754 | 1760 | DEFINE_WAIT(wait); |
|---|
| 1755 | 1761 | |
|---|
| .. | .. |
|---|
| 1763 | 1769 | if (test_and_clear_bit(IVTV_F_I_EV_DEC_STOPPED, &itv->i_flags)) |
|---|
| 1764 | 1770 | ev->type = VIDEO_EVENT_DECODER_STOPPED; |
|---|
| 1765 | 1771 | else if (test_and_clear_bit(IVTV_F_I_EV_VSYNC, &itv->i_flags)) { |
|---|
| 1772 | + unsigned char vsync_field; |
|---|
| 1773 | + |
|---|
| 1766 | 1774 | ev->type = VIDEO_EVENT_VSYNC; |
|---|
| 1767 | | - ev->u.vsync_field = test_bit(IVTV_F_I_EV_VSYNC_FIELD, &itv->i_flags) ? |
|---|
| 1775 | + vsync_field = test_bit(IVTV_F_I_EV_VSYNC_FIELD, &itv->i_flags) ? |
|---|
| 1768 | 1776 | VIDEO_VSYNC_FIELD_ODD : VIDEO_VSYNC_FIELD_EVEN; |
|---|
| 1769 | 1777 | if (itv->output_mode == OUT_UDMA_YUV && |
|---|
| 1770 | 1778 | (itv->yuv_info.lace_mode & IVTV_YUV_MODE_MASK) == |
|---|
| 1771 | 1779 | IVTV_YUV_MODE_PROGRESSIVE) { |
|---|
| 1772 | | - ev->u.vsync_field = VIDEO_VSYNC_FIELD_PROGRESSIVE; |
|---|
| 1780 | + vsync_field = VIDEO_VSYNC_FIELD_PROGRESSIVE; |
|---|
| 1773 | 1781 | } |
|---|
| 1782 | +#ifdef CONFIG_COMPAT |
|---|
| 1783 | + if (cmd == VIDEO_GET_EVENT32) |
|---|
| 1784 | + ev32->u.vsync_field = vsync_field; |
|---|
| 1785 | + else |
|---|
| 1786 | +#endif |
|---|
| 1787 | + ev->u.vsync_field = vsync_field; |
|---|
| 1774 | 1788 | } |
|---|
| 1775 | 1789 | if (ev->type) |
|---|
| 1776 | 1790 | return 0; |
|---|
| .. | .. |
|---|
| 1893 | 1907 | .vidioc_enum_input = ivtv_enum_input, |
|---|
| 1894 | 1908 | .vidioc_enum_output = ivtv_enum_output, |
|---|
| 1895 | 1909 | .vidioc_enumaudout = ivtv_enumaudout, |
|---|
| 1896 | | - .vidioc_cropcap = ivtv_cropcap, |
|---|
| 1910 | + .vidioc_g_pixelaspect = ivtv_g_pixelaspect, |
|---|
| 1897 | 1911 | .vidioc_s_selection = ivtv_s_selection, |
|---|
| 1898 | 1912 | .vidioc_g_selection = ivtv_g_selection, |
|---|
| 1899 | 1913 | .vidioc_g_input = ivtv_g_input, |
|---|