Commit 2600d71c authored by Steven Toth's avatar Steven Toth Committed by Mauro Carvalho Chehab

[media] saa7164: add support for encoder CBR and VBR optionally

Signed-off-by: default avatarSteven Toth <stoth@kernellabs.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 07603131
...@@ -59,7 +59,10 @@ int saa7164_api_set_encoder(struct saa7164_port *port) ...@@ -59,7 +59,10 @@ int saa7164_api_set_encoder(struct saa7164_port *port)
printk(KERN_ERR "%s() error, ret = 0x%x\n", __func__, ret); printk(KERN_ERR "%s() error, ret = 0x%x\n", __func__, ret);
/* Establish video bitrates */ /* Establish video bitrates */
vb.ucVideoBitRateMode = 0; if (port->encoder_params.bitrate_mode == V4L2_MPEG_VIDEO_BITRATE_MODE_CBR)
vb.ucVideoBitRateMode = EU_VIDEO_BIT_RATE_MODE_CONSTANT;
else
vb.ucVideoBitRateMode = EU_VIDEO_BIT_RATE_MODE_VARIABLE_PEAK;
vb.dwVideoBitRate = port->encoder_params.bitrate; vb.dwVideoBitRate = port->encoder_params.bitrate;
vb.dwVideoBitRatePeak = vb.dwVideoBitRate; vb.dwVideoBitRatePeak = vb.dwVideoBitRate;
ret = saa7164_cmd_send(port->dev, port->hwcfg.sourceid, SET_CUR, ret = saa7164_cmd_send(port->dev, port->hwcfg.sourceid, SET_CUR,
......
...@@ -45,6 +45,7 @@ static const u32 saa7164_v4l2_ctrls[] = { ...@@ -45,6 +45,7 @@ static const u32 saa7164_v4l2_ctrls[] = {
V4L2_CID_MPEG_VIDEO_ASPECT, V4L2_CID_MPEG_VIDEO_ASPECT,
V4L2_CID_MPEG_STREAM_TYPE, V4L2_CID_MPEG_STREAM_TYPE,
V4L2_CID_MPEG_AUDIO_MUTE, V4L2_CID_MPEG_AUDIO_MUTE,
V4L2_CID_MPEG_VIDEO_BITRATE_MODE,
V4L2_CID_MPEG_VIDEO_BITRATE, V4L2_CID_MPEG_VIDEO_BITRATE,
0 0
}; };
...@@ -379,6 +380,9 @@ static int saa7164_get_ctrl(struct saa7164_port *port, ...@@ -379,6 +380,9 @@ static int saa7164_get_ctrl(struct saa7164_port *port,
case V4L2_CID_MPEG_VIDEO_ASPECT: case V4L2_CID_MPEG_VIDEO_ASPECT:
ctrl->value = params->ctl_aspect; ctrl->value = params->ctl_aspect;
break; break;
case V4L2_CID_MPEG_VIDEO_BITRATE_MODE:
ctrl->value = params->bitrate_mode;
break;
default: default:
return -EINVAL; return -EINVAL;
} }
...@@ -438,6 +442,11 @@ static int saa7164_try_ctrl(struct v4l2_ext_control *ctrl, int ac3) ...@@ -438,6 +442,11 @@ static int saa7164_try_ctrl(struct v4l2_ext_control *ctrl, int ac3)
(ctrl->value <= 255)) (ctrl->value <= 255))
ret = 0; ret = 0;
break; break;
case V4L2_CID_MPEG_VIDEO_BITRATE_MODE:
if ((ctrl->value == V4L2_MPEG_VIDEO_BITRATE_MODE_VBR) ||
(ctrl->value == V4L2_MPEG_VIDEO_BITRATE_MODE_CBR))
ret = 0;
break;
default: default:
ret = -EINVAL; ret = -EINVAL;
} }
...@@ -497,6 +506,9 @@ static int saa7164_set_ctrl(struct saa7164_port *port, ...@@ -497,6 +506,9 @@ static int saa7164_set_ctrl(struct saa7164_port *port,
ret = -EIO; ret = -EIO;
} }
break; break;
case V4L2_CID_MPEG_VIDEO_BITRATE_MODE:
params->bitrate_mode = ctrl->value;
break;
default: default:
return -EINVAL; return -EINVAL;
} }
...@@ -667,6 +679,10 @@ static int fill_queryctrl(struct saa7164_encoder_params *params, ...@@ -667,6 +679,10 @@ static int fill_queryctrl(struct saa7164_encoder_params *params,
1, V4L2_MPEG_VIDEO_ASPECT_4x3); 1, V4L2_MPEG_VIDEO_ASPECT_4x3);
case V4L2_CID_MPEG_VIDEO_GOP_SIZE: case V4L2_CID_MPEG_VIDEO_GOP_SIZE:
return v4l2_ctrl_query_fill(c, 1, 255, 1, 15); return v4l2_ctrl_query_fill(c, 1, 255, 1, 15);
case V4L2_CID_MPEG_VIDEO_BITRATE_MODE:
return v4l2_ctrl_query_fill(c,
V4L2_MPEG_VIDEO_BITRATE_MODE_VBR, V4L2_MPEG_VIDEO_BITRATE_MODE_CBR,
1, V4L2_MPEG_VIDEO_BITRATE_MODE_VBR);
default: default:
return -EINVAL; return -EINVAL;
} }
...@@ -1287,6 +1303,7 @@ int saa7164_encoder_register(struct saa7164_port *port) ...@@ -1287,6 +1303,7 @@ int saa7164_encoder_register(struct saa7164_port *port)
port->ctl_saturation = 62; port->ctl_saturation = 62;
port->ctl_sharpness = 8; port->ctl_sharpness = 8;
port->encoder_params.bitrate = ENCODER_DEF_BITRATE; port->encoder_params.bitrate = ENCODER_DEF_BITRATE;
port->encoder_params.bitrate_mode = V4L2_MPEG_VIDEO_BITRATE_MODE_VBR;
port->encoder_params.stream_type = V4L2_MPEG_STREAM_TYPE_MPEG2_PS; port->encoder_params.stream_type = V4L2_MPEG_STREAM_TYPE_MPEG2_PS;
port->encoder_params.ctl_mute = 0; port->encoder_params.ctl_mute = 0;
port->encoder_params.ctl_aspect = V4L2_MPEG_VIDEO_ASPECT_4x3; port->encoder_params.ctl_aspect = V4L2_MPEG_VIDEO_ASPECT_4x3;
......
...@@ -311,6 +311,9 @@ typedef struct ...@@ -311,6 +311,9 @@ typedef struct
} __attribute__((packed)) tmComResProcDescrHeader_t; } __attribute__((packed)) tmComResProcDescrHeader_t;
/* Video bitrate control message */ /* Video bitrate control message */
#define EU_VIDEO_BIT_RATE_MODE_CONSTANT (0)
#define EU_VIDEO_BIT_RATE_MODE_VARIABLE_AVERAGE (1)
#define EU_VIDEO_BIT_RATE_MODE_VARIABLE_PEAK (2)
typedef struct typedef struct
{ {
u8 ucVideoBitRateMode; u8 ucVideoBitRateMode;
......
...@@ -255,6 +255,7 @@ struct saa7164_encoder_params { ...@@ -255,6 +255,7 @@ struct saa7164_encoder_params {
u32 width; u32 width;
u32 is_50hz; u32 is_50hz;
u32 bitrate; /* bps */ u32 bitrate; /* bps */
u32 bitrate_mode;
u32 stream_type; /* V4L2_MPEG_STREAM_TYPE_MPEG2_TS */ u32 stream_type; /* V4L2_MPEG_STREAM_TYPE_MPEG2_TS */
u32 audio_sampling_freq; u32 audio_sampling_freq;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment