Skip to content

Commit

Permalink
[media] cx25840: fix VBI support for cx23888
Browse files Browse the repository at this point in the history
The cx23888 has the VBI registers at different addresses compared to
the other variants. In most cases it is a fixed offset, but not always.

Update the code so the right registers are written for the cx23888.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Dec 18, 2015
1 parent 80954cb commit cdf472d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 19 deletions.
20 changes: 10 additions & 10 deletions drivers/media/i2c/cx25840/cx25840-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ static void cx23885_initialize(struct i2c_client *client)
cx25840_write4(client, 0x404, 0x0010253e);

/* CC on - Undocumented Register */
cx25840_write(client, 0x42f, 0x66);
cx25840_write(client, state->vbi_regs_offset + 0x42f, 0x66);

/* HVR-1250 / HVR1850 DIF related */
/* Power everything up */
Expand Down Expand Up @@ -1122,15 +1122,14 @@ static int set_input(struct i2c_client *client, enum cx25840_video_input vid_inp
else
cx25840_write4(client, 0x420, 0x001c8282);

cx25840_write4(client, 0x42c, 0x42600000);
cx25840_write4(client, 0x430, 0x0000039b);
cx25840_write4(client, 0x438, 0x00000000);

cx25840_write4(client, 0x440, 0xF8E3E824);
cx25840_write4(client, 0x444, 0x401040dc);
cx25840_write4(client, 0x448, 0xcd3f02a0);
cx25840_write4(client, 0x44c, 0x161f1000);
cx25840_write4(client, 0x450, 0x00000802);
cx25840_write4(client, state->vbi_regs_offset + 0x42c, 0x42600000);
cx25840_write4(client, state->vbi_regs_offset + 0x430, 0x0000039b);
cx25840_write4(client, state->vbi_regs_offset + 0x438, 0x00000000);
cx25840_write4(client, state->vbi_regs_offset + 0x440, 0xF8E3E824);
cx25840_write4(client, state->vbi_regs_offset + 0x444, 0x401040dc);
cx25840_write4(client, state->vbi_regs_offset + 0x448, 0xcd3f02a0);
cx25840_write4(client, state->vbi_regs_offset + 0x44c, 0x161f1000);
cx25840_write4(client, state->vbi_regs_offset + 0x450, 0x00000802);

cx25840_write4(client, 0x91c, 0x01000000);
cx25840_write4(client, 0x8e0, 0x03063870);
Expand Down Expand Up @@ -5264,6 +5263,7 @@ static int cx25840_probe(struct i2c_client *client,
state->vbi_line_offset = 8;
state->id = id;
state->rev = device_id;
state->vbi_regs_offset = id == CX23888_AV ? 0x500 - 0x424 : 0;
v4l2_ctrl_handler_init(&state->hdl, 9);
v4l2_ctrl_new_std(&state->hdl, &cx25840_ctrl_ops,
V4L2_CID_BRIGHTNESS, 0, 255, 1, 128);
Expand Down
1 change: 1 addition & 0 deletions drivers/media/i2c/cx25840/cx25840-core.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ struct cx25840_state {
enum cx25840_model id;
u32 rev;
int is_initialized;
unsigned vbi_regs_offset;
wait_queue_head_t fw_wait; /* wake up when the fw load is finished */
struct work_struct fw_work; /* work entry for fw load */
struct cx25840_ir_state *ir_state;
Expand Down
32 changes: 23 additions & 9 deletions drivers/media/i2c/cx25840/cx25840-vbi.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ int cx25840_g_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *

if (is_pal) {
for (i = 7; i <= 23; i++) {
u8 v = cx25840_read(client, 0x424 + i - 7);
u8 v = cx25840_read(client,
state->vbi_regs_offset + 0x424 + i - 7);

svbi->service_lines[0][i] = lcr2vbi[v >> 4];
svbi->service_lines[1][i] = lcr2vbi[v & 0xf];
Expand All @@ -113,7 +114,8 @@ int cx25840_g_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *
}
} else {
for (i = 10; i <= 21; i++) {
u8 v = cx25840_read(client, 0x424 + i - 10);
u8 v = cx25840_read(client,
state->vbi_regs_offset + 0x424 + i - 10);

svbi->service_lines[0][i] = lcr2vbi[v >> 4];
svbi->service_lines[1][i] = lcr2vbi[v & 0xf];
Expand All @@ -135,7 +137,10 @@ int cx25840_s_raw_fmt(struct v4l2_subdev *sd, struct v4l2_vbi_format *fmt)
cx25840_std_setup(client);

/* VBI Offset */
cx25840_write(client, 0x47f, vbi_offset);
if (is_cx23888(state))
cx25840_write(client, 0x54f, vbi_offset);
else
cx25840_write(client, 0x47f, vbi_offset);
cx25840_write(client, 0x404, 0x2e);
return 0;
}
Expand All @@ -158,7 +163,10 @@ int cx25840_s_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *
/* Sliced VBI */
cx25840_write(client, 0x404, 0x32); /* Ancillary data */
cx25840_write(client, 0x406, 0x13);
cx25840_write(client, 0x47f, vbi_offset);
if (is_cx23888(state))
cx25840_write(client, 0x54f, vbi_offset);
else
cx25840_write(client, 0x47f, vbi_offset);

if (is_pal) {
for (i = 0; i <= 6; i++)
Expand Down Expand Up @@ -194,17 +202,23 @@ int cx25840_s_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *
}

if (is_pal) {
for (x = 1, i = 0x424; i <= 0x434; i++, x++)
for (x = 1, i = state->vbi_regs_offset + 0x424;
i <= state->vbi_regs_offset + 0x434; i++, x++)
cx25840_write(client, i, lcr[6 + x]);
} else {
for (x = 1, i = 0x424; i <= 0x430; i++, x++)
for (x = 1, i = state->vbi_regs_offset + 0x424;
i <= state->vbi_regs_offset + 0x430; i++, x++)
cx25840_write(client, i, lcr[9 + x]);
for (i = 0x431; i <= 0x434; i++)
for (i = state->vbi_regs_offset + 0x431;
i <= state->vbi_regs_offset + 0x434; i++)
cx25840_write(client, i, 0);
}

cx25840_write(client, 0x43c, 0x16);
cx25840_write(client, 0x474, is_pal ? 0x2a : 0x22);
cx25840_write(client, state->vbi_regs_offset + 0x43c, 0x16);
if (is_cx23888(state))
cx25840_write(client, 0x428, is_pal ? 0x2a : 0x22);
else
cx25840_write(client, 0x474, is_pal ? 0x2a : 0x22);
return 0;
}

Expand Down

0 comments on commit cdf472d

Please sign in to comment.