summaryrefslogtreecommitdiff
path: root/linux/drivers/media/video/saa6752hs.c
diff options
context:
space:
mode:
Diffstat (limited to 'linux/drivers/media/video/saa6752hs.c')
-rw-r--r--linux/drivers/media/video/saa6752hs.c98
1 files changed, 49 insertions, 49 deletions
diff --git a/linux/drivers/media/video/saa6752hs.c b/linux/drivers/media/video/saa6752hs.c
index 312173d5c..d37215ebb 100644
--- a/linux/drivers/media/video/saa6752hs.c
+++ b/linux/drivers/media/video/saa6752hs.c
@@ -262,8 +262,48 @@ static int saa6752hs_set_bitrate(struct i2c_client* client,
}
-static int saa6752hs_init(struct i2c_client* client,
- struct v4l2_mpeg_compression* params)
+static int saa6752hs_set_params(struct i2c_client* client,
+ struct v4l2_mpeg_compression* params)
+{
+ struct saa6752hs_state *h = i2c_get_clientdata(client);
+
+ /* check PIDs */
+ if (params->ts_pid_pmt <= MPEG_PID_MAX)
+ h->params.ts_pid_pmt = params->ts_pid_pmt;
+ if (params->ts_pid_pcr <= MPEG_PID_MAX)
+ h->params.ts_pid_pcr = params->ts_pid_pcr;
+ if (params->ts_pid_video <= MPEG_PID_MAX)
+ h->params.ts_pid_video = params->ts_pid_video;
+ if (params->ts_pid_audio <= MPEG_PID_MAX)
+ h->params.ts_pid_audio = params->ts_pid_audio;
+
+ /* check bitrate parameters */
+ if ((params->vi_bitrate.mode == V4L2_BITRATE_CBR) ||
+ (params->vi_bitrate.mode == V4L2_BITRATE_VBR))
+ h->params.vi_bitrate.mode = params->vi_bitrate.mode;
+ if (params->vi_bitrate.mode != V4L2_BITRATE_NONE)
+ h->params.st_bitrate.target = params->st_bitrate.target;
+ if (params->vi_bitrate.mode != V4L2_BITRATE_NONE)
+ h->params.vi_bitrate.target = params->vi_bitrate.target;
+ if (params->vi_bitrate.mode == V4L2_BITRATE_VBR)
+ h->params.vi_bitrate.max = params->vi_bitrate.max;
+ if (params->au_bitrate.mode != V4L2_BITRATE_NONE)
+ h->params.au_bitrate.target = params->au_bitrate.target;
+
+ /* range checks */
+ if (h->params.st_bitrate.target > MPEG_TOTAL_TARGET_BITRATE_MAX)
+ h->params.st_bitrate.target = MPEG_TOTAL_TARGET_BITRATE_MAX;
+ if (h->params.vi_bitrate.target > MPEG_VIDEO_TARGET_BITRATE_MAX)
+ h->params.vi_bitrate.target = MPEG_VIDEO_TARGET_BITRATE_MAX;
+ if (h->params.vi_bitrate.max > MPEG_VIDEO_MAX_BITRATE_MAX)
+ h->params.vi_bitrate.max = MPEG_VIDEO_MAX_BITRATE_MAX;
+ if (h->params.au_bitrate.target <= 256)
+ h->params.au_bitrate.target = 256;
+ else
+ h->params.au_bitrate.target = 384;
+}
+
+static int saa6752hs_init(struct i2c_client* client)
{
unsigned char buf[3];
struct saa6752hs_state *h;
@@ -271,50 +311,8 @@ static int saa6752hs_init(struct i2c_client* client,
unsigned char localPAT[256];
unsigned char localPMT[256];
- // grab the previous set of parameters
h = i2c_get_clientdata(client);
- // check the bitrate parameters first
- if (params != NULL) {
- /* check PIDs */
- if (params->ts_pid_pmt <= MPEG_PID_MAX)
- h->params.ts_pid_pmt = params->ts_pid_pmt;
- if (params->ts_pid_pcr <= MPEG_PID_MAX)
- h->params.ts_pid_pcr = params->ts_pid_pcr;
- if (params->ts_pid_video <= MPEG_PID_MAX)
- h->params.ts_pid_video = params->ts_pid_video;
- if (params->ts_pid_audio <= MPEG_PID_MAX)
- h->params.ts_pid_audio = params->ts_pid_audio;
-
- /* check bitrate parameters */
- if ((params->vi_bitrate.mode == V4L2_BITRATE_CBR) ||
- (params->vi_bitrate.mode == V4L2_BITRATE_VBR))
- h->params.vi_bitrate.mode = params->vi_bitrate.mode;
- if (params->vi_bitrate.mode != V4L2_BITRATE_NONE)
- h->params.st_bitrate.target = params->st_bitrate.target;
- if (params->vi_bitrate.mode != V4L2_BITRATE_NONE)
- h->params.vi_bitrate.target = params->vi_bitrate.target;
- if (params->vi_bitrate.mode == V4L2_BITRATE_VBR)
- h->params.vi_bitrate.max = params->vi_bitrate.max;
- if (params->au_bitrate.mode != V4L2_BITRATE_NONE)
- h->params.au_bitrate.target = params->au_bitrate.target;
-
- /* range checks */
- if (h->params.st_bitrate.target > MPEG_TOTAL_TARGET_BITRATE_MAX)
- h->params.st_bitrate.target = MPEG_TOTAL_TARGET_BITRATE_MAX;
- if (h->params.vi_bitrate.target > MPEG_VIDEO_TARGET_BITRATE_MAX)
- h->params.vi_bitrate.target = MPEG_VIDEO_TARGET_BITRATE_MAX;
- if (h->params.vi_bitrate.max > MPEG_VIDEO_MAX_BITRATE_MAX)
- h->params.vi_bitrate.max = MPEG_VIDEO_MAX_BITRATE_MAX;
- if (h->params.au_bitrate.target <= 256)
- h->params.au_bitrate.target = 256;
- else
- h->params.au_bitrate.target = 384;
-
- /* return actually used settings */
- *params = h->params;
- }
-
// set bitrate
saa6752hs_set_bitrate(client, &h->params);
@@ -427,8 +425,6 @@ static int saa6752hs_attach(struct i2c_adapter *adap, int addr, int kind)
i2c_set_clientdata(&h->client, h);
i2c_attach_client(&h->client);
-
- saa6752hs_init(&h->client, NULL);
return 0;
}
@@ -458,11 +454,15 @@ saa6752hs_command(struct i2c_client *client, unsigned int cmd, void *arg)
switch (cmd) {
case VIDIOC_S_MPEGCOMP:
- err = saa6752hs_init(client, params);
+ if (NULL == params) {
+ /* apply settings and start encoder */
+ saa6752hs_init(client);
+ break;
+ }
+ err = saa6752hs_set_params(client, params);
/* fall through */
case VIDIOC_G_MPEGCOMP:
- if (params)
- *params = h->params;
+ *params = h->params;
break;
default:
/* nothing */