[media] s2255: Add ENUM_FRAMESIZES support
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
parent
3c728118e0
commit
05e5d44b07
@ -1545,36 +1545,64 @@ static int vidioc_s_parm(struct file *file, void *priv,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define NUM_SIZE_ENUMS 3
|
||||||
|
static const struct v4l2_frmsize_discrete ntsc_sizes[] = {
|
||||||
|
{ 640, 480 },
|
||||||
|
{ 640, 240 },
|
||||||
|
{ 320, 240 },
|
||||||
|
};
|
||||||
|
static const struct v4l2_frmsize_discrete pal_sizes[] = {
|
||||||
|
{ 704, 576 },
|
||||||
|
{ 704, 288 },
|
||||||
|
{ 352, 288 },
|
||||||
|
};
|
||||||
|
|
||||||
|
static int vidioc_enum_framesizes(struct file *file, void *priv,
|
||||||
|
struct v4l2_frmsizeenum *fe)
|
||||||
|
{
|
||||||
|
struct s2255_fh *fh = priv;
|
||||||
|
struct s2255_channel *channel = fh->channel;
|
||||||
|
int is_ntsc = channel->std & V4L2_STD_525_60;
|
||||||
|
const struct s2255_fmt *fmt;
|
||||||
|
|
||||||
|
if (fe->index >= NUM_SIZE_ENUMS)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
fmt = format_by_fourcc(fe->pixel_format);
|
||||||
|
if (fmt == NULL)
|
||||||
|
return -EINVAL;
|
||||||
|
fe->type = V4L2_FRMSIZE_TYPE_DISCRETE;
|
||||||
|
fe->discrete = is_ntsc ? ntsc_sizes[fe->index] : pal_sizes[fe->index];
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int vidioc_enum_frameintervals(struct file *file, void *priv,
|
static int vidioc_enum_frameintervals(struct file *file, void *priv,
|
||||||
struct v4l2_frmivalenum *fe)
|
struct v4l2_frmivalenum *fe)
|
||||||
{
|
{
|
||||||
int is_ntsc = 0;
|
struct s2255_fh *fh = priv;
|
||||||
|
struct s2255_channel *channel = fh->channel;
|
||||||
|
const struct s2255_fmt *fmt;
|
||||||
|
const struct v4l2_frmsize_discrete *sizes;
|
||||||
|
int is_ntsc = channel->std & V4L2_STD_525_60;
|
||||||
#define NUM_FRAME_ENUMS 4
|
#define NUM_FRAME_ENUMS 4
|
||||||
int frm_dec[NUM_FRAME_ENUMS] = {1, 2, 3, 5};
|
int frm_dec[NUM_FRAME_ENUMS] = {1, 2, 3, 5};
|
||||||
|
int i;
|
||||||
|
|
||||||
if (fe->index >= NUM_FRAME_ENUMS)
|
if (fe->index >= NUM_FRAME_ENUMS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
switch (fe->width) {
|
|
||||||
case 640:
|
fmt = format_by_fourcc(fe->pixel_format);
|
||||||
if (fe->height != 240 && fe->height != 480)
|
if (fmt == NULL)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
is_ntsc = 1;
|
|
||||||
|
sizes = is_ntsc ? ntsc_sizes : pal_sizes;
|
||||||
|
for (i = 0; i < NUM_SIZE_ENUMS; i++, sizes++)
|
||||||
|
if (fe->width == sizes->width &&
|
||||||
|
fe->height == sizes->height)
|
||||||
break;
|
break;
|
||||||
case 320:
|
if (i == NUM_SIZE_ENUMS)
|
||||||
if (fe->height != 240)
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
is_ntsc = 1;
|
|
||||||
break;
|
|
||||||
case 704:
|
|
||||||
if (fe->height != 288 && fe->height != 576)
|
|
||||||
return -EINVAL;
|
|
||||||
break;
|
|
||||||
case 352:
|
|
||||||
if (fe->height != 288)
|
|
||||||
return -EINVAL;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
fe->type = V4L2_FRMIVAL_TYPE_DISCRETE;
|
fe->type = V4L2_FRMIVAL_TYPE_DISCRETE;
|
||||||
fe->discrete.denominator = is_ntsc ? 30000 : 25000;
|
fe->discrete.denominator = is_ntsc ? 30000 : 25000;
|
||||||
fe->discrete.numerator = (is_ntsc ? 1001 : 1000) * frm_dec[fe->index];
|
fe->discrete.numerator = (is_ntsc ? 1001 : 1000) * frm_dec[fe->index];
|
||||||
@ -1813,6 +1841,7 @@ static const struct v4l2_ioctl_ops s2255_ioctl_ops = {
|
|||||||
.vidioc_g_jpegcomp = vidioc_g_jpegcomp,
|
.vidioc_g_jpegcomp = vidioc_g_jpegcomp,
|
||||||
.vidioc_s_parm = vidioc_s_parm,
|
.vidioc_s_parm = vidioc_s_parm,
|
||||||
.vidioc_g_parm = vidioc_g_parm,
|
.vidioc_g_parm = vidioc_g_parm,
|
||||||
|
.vidioc_enum_framesizes = vidioc_enum_framesizes,
|
||||||
.vidioc_enum_frameintervals = vidioc_enum_frameintervals,
|
.vidioc_enum_frameintervals = vidioc_enum_frameintervals,
|
||||||
.vidioc_log_status = v4l2_ctrl_log_status,
|
.vidioc_log_status = v4l2_ctrl_log_status,
|
||||||
.vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
|
.vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user