aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/i2c/cx25840
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2015-11-30 07:09:50 -0500
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-12-18 10:31:24 -0500
commitcdf472d32a5a1a99c54c3df5c155785db2e529c3 (patch)
treeae8f8f597b9675b71ad9c1fc621b51d51dd77389 /drivers/media/i2c/cx25840
parent80954cbbe431bcc43af6d8c8d39a83fa016dffdf (diff)
[media] cx25840: fix VBI support for cx23888
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>
Diffstat (limited to 'drivers/media/i2c/cx25840')
-rw-r--r--drivers/media/i2c/cx25840/cx25840-core.c20
-rw-r--r--drivers/media/i2c/cx25840/cx25840-core.h1
-rw-r--r--drivers/media/i2c/cx25840/cx25840-vbi.c32
3 files changed, 34 insertions, 19 deletions
diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c
index 181fdc14c6c6..ec11ba74d37c 100644
--- a/drivers/media/i2c/cx25840/cx25840-core.c
+++ b/drivers/media/i2c/cx25840/cx25840-core.c
@@ -666,7 +666,7 @@ static void cx23885_initialize(struct i2c_client *client)
666 cx25840_write4(client, 0x404, 0x0010253e); 666 cx25840_write4(client, 0x404, 0x0010253e);
667 667
668 /* CC on - Undocumented Register */ 668 /* CC on - Undocumented Register */
669 cx25840_write(client, 0x42f, 0x66); 669 cx25840_write(client, state->vbi_regs_offset + 0x42f, 0x66);
670 670
671 /* HVR-1250 / HVR1850 DIF related */ 671 /* HVR-1250 / HVR1850 DIF related */
672 /* Power everything up */ 672 /* Power everything up */
@@ -1122,15 +1122,14 @@ static int set_input(struct i2c_client *client, enum cx25840_video_input vid_inp
1122 else 1122 else
1123 cx25840_write4(client, 0x420, 0x001c8282); 1123 cx25840_write4(client, 0x420, 0x001c8282);
1124 1124
1125 cx25840_write4(client, 0x42c, 0x42600000); 1125 cx25840_write4(client, state->vbi_regs_offset + 0x42c, 0x42600000);
1126 cx25840_write4(client, 0x430, 0x0000039b); 1126 cx25840_write4(client, state->vbi_regs_offset + 0x430, 0x0000039b);
1127 cx25840_write4(client, 0x438, 0x00000000); 1127 cx25840_write4(client, state->vbi_regs_offset + 0x438, 0x00000000);
1128 1128 cx25840_write4(client, state->vbi_regs_offset + 0x440, 0xF8E3E824);
1129 cx25840_write4(client, 0x440, 0xF8E3E824); 1129 cx25840_write4(client, state->vbi_regs_offset + 0x444, 0x401040dc);
1130 cx25840_write4(client, 0x444, 0x401040dc); 1130 cx25840_write4(client, state->vbi_regs_offset + 0x448, 0xcd3f02a0);
1131 cx25840_write4(client, 0x448, 0xcd3f02a0); 1131 cx25840_write4(client, state->vbi_regs_offset + 0x44c, 0x161f1000);
1132 cx25840_write4(client, 0x44c, 0x161f1000); 1132 cx25840_write4(client, state->vbi_regs_offset + 0x450, 0x00000802);
1133 cx25840_write4(client, 0x450, 0x00000802);
1134 1133
1135 cx25840_write4(client, 0x91c, 0x01000000); 1134 cx25840_write4(client, 0x91c, 0x01000000);
1136 cx25840_write4(client, 0x8e0, 0x03063870); 1135 cx25840_write4(client, 0x8e0, 0x03063870);
@@ -5264,6 +5263,7 @@ static int cx25840_probe(struct i2c_client *client,
5264 state->vbi_line_offset = 8; 5263 state->vbi_line_offset = 8;
5265 state->id = id; 5264 state->id = id;
5266 state->rev = device_id; 5265 state->rev = device_id;
5266 state->vbi_regs_offset = id == CX23888_AV ? 0x500 - 0x424 : 0;
5267 v4l2_ctrl_handler_init(&state->hdl, 9); 5267 v4l2_ctrl_handler_init(&state->hdl, 9);
5268 v4l2_ctrl_new_std(&state->hdl, &cx25840_ctrl_ops, 5268 v4l2_ctrl_new_std(&state->hdl, &cx25840_ctrl_ops,
5269 V4L2_CID_BRIGHTNESS, 0, 255, 1, 128); 5269 V4L2_CID_BRIGHTNESS, 0, 255, 1, 128);
diff --git a/drivers/media/i2c/cx25840/cx25840-core.h b/drivers/media/i2c/cx25840/cx25840-core.h
index fdea48ce0c03..254ef45ce41a 100644
--- a/drivers/media/i2c/cx25840/cx25840-core.h
+++ b/drivers/media/i2c/cx25840/cx25840-core.h
@@ -69,6 +69,7 @@ struct cx25840_state {
69 enum cx25840_model id; 69 enum cx25840_model id;
70 u32 rev; 70 u32 rev;
71 int is_initialized; 71 int is_initialized;
72 unsigned vbi_regs_offset;
72 wait_queue_head_t fw_wait; /* wake up when the fw load is finished */ 73 wait_queue_head_t fw_wait; /* wake up when the fw load is finished */
73 struct work_struct fw_work; /* work entry for fw load */ 74 struct work_struct fw_work; /* work entry for fw load */
74 struct cx25840_ir_state *ir_state; 75 struct cx25840_ir_state *ir_state;
diff --git a/drivers/media/i2c/cx25840/cx25840-vbi.c b/drivers/media/i2c/cx25840/cx25840-vbi.c
index 04034c592603..0470bb6128e1 100644
--- a/drivers/media/i2c/cx25840/cx25840-vbi.c
+++ b/drivers/media/i2c/cx25840/cx25840-vbi.c
@@ -104,7 +104,8 @@ int cx25840_g_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *
104 104
105 if (is_pal) { 105 if (is_pal) {
106 for (i = 7; i <= 23; i++) { 106 for (i = 7; i <= 23; i++) {
107 u8 v = cx25840_read(client, 0x424 + i - 7); 107 u8 v = cx25840_read(client,
108 state->vbi_regs_offset + 0x424 + i - 7);
108 109
109 svbi->service_lines[0][i] = lcr2vbi[v >> 4]; 110 svbi->service_lines[0][i] = lcr2vbi[v >> 4];
110 svbi->service_lines[1][i] = lcr2vbi[v & 0xf]; 111 svbi->service_lines[1][i] = lcr2vbi[v & 0xf];
@@ -113,7 +114,8 @@ int cx25840_g_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *
113 } 114 }
114 } else { 115 } else {
115 for (i = 10; i <= 21; i++) { 116 for (i = 10; i <= 21; i++) {
116 u8 v = cx25840_read(client, 0x424 + i - 10); 117 u8 v = cx25840_read(client,
118 state->vbi_regs_offset + 0x424 + i - 10);
117 119
118 svbi->service_lines[0][i] = lcr2vbi[v >> 4]; 120 svbi->service_lines[0][i] = lcr2vbi[v >> 4];
119 svbi->service_lines[1][i] = lcr2vbi[v & 0xf]; 121 svbi->service_lines[1][i] = lcr2vbi[v & 0xf];
@@ -135,7 +137,10 @@ int cx25840_s_raw_fmt(struct v4l2_subdev *sd, struct v4l2_vbi_format *fmt)
135 cx25840_std_setup(client); 137 cx25840_std_setup(client);
136 138
137 /* VBI Offset */ 139 /* VBI Offset */
138 cx25840_write(client, 0x47f, vbi_offset); 140 if (is_cx23888(state))
141 cx25840_write(client, 0x54f, vbi_offset);
142 else
143 cx25840_write(client, 0x47f, vbi_offset);
139 cx25840_write(client, 0x404, 0x2e); 144 cx25840_write(client, 0x404, 0x2e);
140 return 0; 145 return 0;
141} 146}
@@ -158,7 +163,10 @@ int cx25840_s_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *
158 /* Sliced VBI */ 163 /* Sliced VBI */
159 cx25840_write(client, 0x404, 0x32); /* Ancillary data */ 164 cx25840_write(client, 0x404, 0x32); /* Ancillary data */
160 cx25840_write(client, 0x406, 0x13); 165 cx25840_write(client, 0x406, 0x13);
161 cx25840_write(client, 0x47f, vbi_offset); 166 if (is_cx23888(state))
167 cx25840_write(client, 0x54f, vbi_offset);
168 else
169 cx25840_write(client, 0x47f, vbi_offset);
162 170
163 if (is_pal) { 171 if (is_pal) {
164 for (i = 0; i <= 6; i++) 172 for (i = 0; i <= 6; i++)
@@ -194,17 +202,23 @@ int cx25840_s_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *
194 } 202 }
195 203
196 if (is_pal) { 204 if (is_pal) {
197 for (x = 1, i = 0x424; i <= 0x434; i++, x++) 205 for (x = 1, i = state->vbi_regs_offset + 0x424;
206 i <= state->vbi_regs_offset + 0x434; i++, x++)
198 cx25840_write(client, i, lcr[6 + x]); 207 cx25840_write(client, i, lcr[6 + x]);
199 } else { 208 } else {
200 for (x = 1, i = 0x424; i <= 0x430; i++, x++) 209 for (x = 1, i = state->vbi_regs_offset + 0x424;
210 i <= state->vbi_regs_offset + 0x430; i++, x++)
201 cx25840_write(client, i, lcr[9 + x]); 211 cx25840_write(client, i, lcr[9 + x]);
202 for (i = 0x431; i <= 0x434; i++) 212 for (i = state->vbi_regs_offset + 0x431;
213 i <= state->vbi_regs_offset + 0x434; i++)
203 cx25840_write(client, i, 0); 214 cx25840_write(client, i, 0);
204 } 215 }
205 216
206 cx25840_write(client, 0x43c, 0x16); 217 cx25840_write(client, state->vbi_regs_offset + 0x43c, 0x16);
207 cx25840_write(client, 0x474, is_pal ? 0x2a : 0x22); 218 if (is_cx23888(state))
219 cx25840_write(client, 0x428, is_pal ? 0x2a : 0x22);
220 else
221 cx25840_write(client, 0x474, is_pal ? 0x2a : 0x22);
208 return 0; 222 return 0;
209} 223}
210 224