diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2013-02-15 04:09:18 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2013-03-05 13:41:26 -0500 |
commit | 05e5d44b078fdd628a2b47c294dd78bbca524afc (patch) | |
tree | c153fc3cb8d7f48603b2c86347caacbecbaffbe1 | |
parent | 3c728118e00c42a177f9a5d0295b2a08591bddcb (diff) |
[media] s2255: Add ENUM_FRAMESIZES support
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/usb/s2255/s2255drv.c | 73 |
1 files changed, 51 insertions, 22 deletions
diff --git a/drivers/media/usb/s2255/s2255drv.c b/drivers/media/usb/s2255/s2255drv.c index eaae9d167e76..59d40e614e94 100644 --- a/drivers/media/usb/s2255/s2255drv.c +++ b/drivers/media/usb/s2255/s2255drv.c | |||
@@ -1545,36 +1545,64 @@ static int vidioc_s_parm(struct file *file, void *priv, | |||
1545 | return 0; | 1545 | return 0; |
1546 | } | 1546 | } |
1547 | 1547 | ||
1548 | #define NUM_SIZE_ENUMS 3 | ||
1549 | static const struct v4l2_frmsize_discrete ntsc_sizes[] = { | ||
1550 | { 640, 480 }, | ||
1551 | { 640, 240 }, | ||
1552 | { 320, 240 }, | ||
1553 | }; | ||
1554 | static const struct v4l2_frmsize_discrete pal_sizes[] = { | ||
1555 | { 704, 576 }, | ||
1556 | { 704, 288 }, | ||
1557 | { 352, 288 }, | ||
1558 | }; | ||
1559 | |||
1560 | static int vidioc_enum_framesizes(struct file *file, void *priv, | ||
1561 | struct v4l2_frmsizeenum *fe) | ||
1562 | { | ||
1563 | struct s2255_fh *fh = priv; | ||
1564 | struct s2255_channel *channel = fh->channel; | ||
1565 | int is_ntsc = channel->std & V4L2_STD_525_60; | ||
1566 | const struct s2255_fmt *fmt; | ||
1567 | |||
1568 | if (fe->index >= NUM_SIZE_ENUMS) | ||
1569 | return -EINVAL; | ||
1570 | |||
1571 | fmt = format_by_fourcc(fe->pixel_format); | ||
1572 | if (fmt == NULL) | ||
1573 | return -EINVAL; | ||
1574 | fe->type = V4L2_FRMSIZE_TYPE_DISCRETE; | ||
1575 | fe->discrete = is_ntsc ? ntsc_sizes[fe->index] : pal_sizes[fe->index]; | ||
1576 | return 0; | ||
1577 | } | ||
1578 | |||
1548 | static int vidioc_enum_frameintervals(struct file *file, void *priv, | 1579 | static int vidioc_enum_frameintervals(struct file *file, void *priv, |
1549 | struct v4l2_frmivalenum *fe) | 1580 | struct v4l2_frmivalenum *fe) |
1550 | { | 1581 | { |
1551 | int is_ntsc = 0; | 1582 | struct s2255_fh *fh = priv; |
1583 | struct s2255_channel *channel = fh->channel; | ||
1584 | const struct s2255_fmt *fmt; | ||
1585 | const struct v4l2_frmsize_discrete *sizes; | ||
1586 | int is_ntsc = channel->std & V4L2_STD_525_60; | ||
1552 | #define NUM_FRAME_ENUMS 4 | 1587 | #define NUM_FRAME_ENUMS 4 |
1553 | int frm_dec[NUM_FRAME_ENUMS] = {1, 2, 3, 5}; | 1588 | int frm_dec[NUM_FRAME_ENUMS] = {1, 2, 3, 5}; |
1589 | int i; | ||
1590 | |||
1554 | if (fe->index >= NUM_FRAME_ENUMS) | 1591 | if (fe->index >= NUM_FRAME_ENUMS) |
1555 | return -EINVAL; | 1592 | return -EINVAL; |
1556 | switch (fe->width) { | 1593 | |
1557 | case 640: | 1594 | fmt = format_by_fourcc(fe->pixel_format); |
1558 | if (fe->height != 240 && fe->height != 480) | 1595 | if (fmt == NULL) |
1559 | return -EINVAL; | ||
1560 | is_ntsc = 1; | ||
1561 | break; | ||
1562 | case 320: | ||
1563 | if (fe->height != 240) | ||
1564 | return -EINVAL; | ||
1565 | is_ntsc = 1; | ||
1566 | break; | ||
1567 | case 704: | ||
1568 | if (fe->height != 288 && fe->height != 576) | ||
1569 | return -EINVAL; | ||
1570 | break; | ||
1571 | case 352: | ||
1572 | if (fe->height != 288) | ||
1573 | return -EINVAL; | ||
1574 | break; | ||
1575 | default: | ||
1576 | return -EINVAL; | 1596 | return -EINVAL; |
1577 | } | 1597 | |
1598 | sizes = is_ntsc ? ntsc_sizes : pal_sizes; | ||
1599 | for (i = 0; i < NUM_SIZE_ENUMS; i++, sizes++) | ||
1600 | if (fe->width == sizes->width && | ||
1601 | fe->height == sizes->height) | ||
1602 | break; | ||
1603 | if (i == NUM_SIZE_ENUMS) | ||
1604 | return -EINVAL; | ||
1605 | |||
1578 | fe->type = V4L2_FRMIVAL_TYPE_DISCRETE; | 1606 | fe->type = V4L2_FRMIVAL_TYPE_DISCRETE; |
1579 | fe->discrete.denominator = is_ntsc ? 30000 : 25000; | 1607 | fe->discrete.denominator = is_ntsc ? 30000 : 25000; |
1580 | fe->discrete.numerator = (is_ntsc ? 1001 : 1000) * frm_dec[fe->index]; | 1608 | fe->discrete.numerator = (is_ntsc ? 1001 : 1000) * frm_dec[fe->index]; |
@@ -1813,6 +1841,7 @@ static const struct v4l2_ioctl_ops s2255_ioctl_ops = { | |||
1813 | .vidioc_g_jpegcomp = vidioc_g_jpegcomp, | 1841 | .vidioc_g_jpegcomp = vidioc_g_jpegcomp, |
1814 | .vidioc_s_parm = vidioc_s_parm, | 1842 | .vidioc_s_parm = vidioc_s_parm, |
1815 | .vidioc_g_parm = vidioc_g_parm, | 1843 | .vidioc_g_parm = vidioc_g_parm, |
1844 | .vidioc_enum_framesizes = vidioc_enum_framesizes, | ||
1816 | .vidioc_enum_frameintervals = vidioc_enum_frameintervals, | 1845 | .vidioc_enum_frameintervals = vidioc_enum_frameintervals, |
1817 | .vidioc_log_status = v4l2_ctrl_log_status, | 1846 | .vidioc_log_status = v4l2_ctrl_log_status, |
1818 | .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, | 1847 | .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, |