aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx18
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2009-03-29 18:20:26 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-04-06 20:44:21 -0400
commitcc26b076cf8b1040ccc514302ef9a24042272ec3 (patch)
tree6b41545a2d59f531cffd32d7161dcabc1d40d0e1 /drivers/media/video/cx18
parent7c9fc9d50f97c9a6733ff1a22b6e31bcd91778e2 (diff)
V4L/DVB (11369): v4l2-subdev: add load_fw and use that instead of abusing core->init.
The init callback was used in several places to load firmware. Make a separate load_fw callback for that. This makes the code a lot more understandable. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/cx18')
-rw-r--r--drivers/media/video/cx18/cx18-av-core.c60
-rw-r--r--drivers/media/video/cx18/cx18-av-core.h5
-rw-r--r--drivers/media/video/cx18/cx18-driver.c4
3 files changed, 32 insertions, 37 deletions
diff --git a/drivers/media/video/cx18/cx18-av-core.c b/drivers/media/video/cx18/cx18-av-core.c
index f4dd9d78eb3d..0c58e55fdbee 100644
--- a/drivers/media/video/cx18/cx18-av-core.c
+++ b/drivers/media/video/cx18/cx18-av-core.c
@@ -203,43 +203,42 @@ static int cx18_av_reset(struct v4l2_subdev *sd, u32 val)
203 203
204static int cx18_av_init(struct v4l2_subdev *sd, u32 val) 204static int cx18_av_init(struct v4l2_subdev *sd, u32 val)
205{ 205{
206 struct cx18_av_state *state = to_cx18_av_state(sd);
207 struct cx18 *cx = v4l2_get_subdevdata(sd); 206 struct cx18 *cx = v4l2_get_subdevdata(sd);
208 207
209 switch (val) { 208 /*
210 case CX18_AV_INIT_PLLS: 209 * The crystal freq used in calculations in this driver will be
211 /* 210 * 28.636360 MHz.
212 * The crystal freq used in calculations in this driver will be 211 * Aim to run the PLLs' VCOs near 400 MHz to minimze errors.
213 * 28.636360 MHz. 212 */
214 * Aim to run the PLLs' VCOs near 400 MHz to minimze errors.
215 */
216 213
217 /* 214 /*
218 * VDCLK Integer = 0x0f, Post Divider = 0x04 215 * VDCLK Integer = 0x0f, Post Divider = 0x04
219 * AIMCLK Integer = 0x0e, Post Divider = 0x16 216 * AIMCLK Integer = 0x0e, Post Divider = 0x16
220 */ 217 */
221 cx18_av_write4(cx, CXADEC_PLL_CTRL1, 0x160e040f); 218 cx18_av_write4(cx, CXADEC_PLL_CTRL1, 0x160e040f);
222 219
223 /* VDCLK Fraction = 0x2be2fe */ 220 /* VDCLK Fraction = 0x2be2fe */
224 /* xtal * 0xf.15f17f0/4 = 108 MHz: 432 MHz before post divide */ 221 /* xtal * 0xf.15f17f0/4 = 108 MHz: 432 MHz before post divide */
225 cx18_av_write4(cx, CXADEC_VID_PLL_FRAC, 0x002be2fe); 222 cx18_av_write4(cx, CXADEC_VID_PLL_FRAC, 0x002be2fe);
226 223
227 /* AIMCLK Fraction = 0x05227ad */ 224 /* AIMCLK Fraction = 0x05227ad */
228 /* xtal * 0xe.2913d68/0x16 = 48000 * 384: 406 MHz pre post-div*/ 225 /* xtal * 0xe.2913d68/0x16 = 48000 * 384: 406 MHz pre post-div*/
229 cx18_av_write4(cx, CXADEC_AUX_PLL_FRAC, 0x005227ad); 226 cx18_av_write4(cx, CXADEC_AUX_PLL_FRAC, 0x005227ad);
230 227
231 /* SA_MCLK_SEL=1, SA_MCLK_DIV=0x16 */ 228 /* SA_MCLK_SEL=1, SA_MCLK_DIV=0x16 */
232 cx18_av_write(cx, CXADEC_I2S_MCLK, 0x56); 229 cx18_av_write(cx, CXADEC_I2S_MCLK, 0x56);
233 break; 230 return 0;
231}
234 232
235 case CX18_AV_INIT_NORMAL: 233static int cx18_av_load_fw(struct v4l2_subdev *sd)
236 default: 234{
237 if (!state->is_initialized) { 235 struct cx18_av_state *state = to_cx18_av_state(sd);
238 /* initialize on first use */ 236 struct cx18 *cx = v4l2_get_subdevdata(sd);
239 state->is_initialized = 1; 237
240 cx18_av_initialize(cx); 238 if (!state->is_initialized) {
241 } 239 /* initialize on first use */
242 break; 240 state->is_initialized = 1;
241 cx18_av_initialize(cx);
243 } 242 }
244 return 0; 243 return 0;
245} 244}
@@ -1185,6 +1184,7 @@ static const struct v4l2_subdev_core_ops cx18_av_general_ops = {
1185 .g_chip_ident = cx18_av_g_chip_ident, 1184 .g_chip_ident = cx18_av_g_chip_ident,
1186 .log_status = cx18_av_log_status, 1185 .log_status = cx18_av_log_status,
1187 .init = cx18_av_init, 1186 .init = cx18_av_init,
1187 .load_fw = cx18_av_load_fw,
1188 .reset = cx18_av_reset, 1188 .reset = cx18_av_reset,
1189 .queryctrl = cx18_av_queryctrl, 1189 .queryctrl = cx18_av_queryctrl,
1190 .g_ctrl = cx18_av_g_ctrl, 1190 .g_ctrl = cx18_av_g_ctrl,
diff --git a/drivers/media/video/cx18/cx18-av-core.h b/drivers/media/video/cx18/cx18-av-core.h
index c458120e8c90..9b84a0c58e0e 100644
--- a/drivers/media/video/cx18/cx18-av-core.h
+++ b/drivers/media/video/cx18/cx18-av-core.h
@@ -328,11 +328,6 @@ static inline struct cx18_av_state *to_cx18_av_state(struct v4l2_subdev *sd)
328 return container_of(sd, struct cx18_av_state, sd); 328 return container_of(sd, struct cx18_av_state, sd);
329} 329}
330 330
331enum cx18_av_subdev_init_arg {
332 CX18_AV_INIT_NORMAL = 0,
333 CX18_AV_INIT_PLLS = 1,
334};
335
336/* ----------------------------------------------------------------------- */ 331/* ----------------------------------------------------------------------- */
337/* cx18_av-core.c */ 332/* cx18_av-core.c */
338int cx18_av_write(struct cx18 *cx, u16 addr, u8 value); 333int cx18_av_write(struct cx18 *cx, u16 addr, u8 value);
diff --git a/drivers/media/video/cx18/cx18-driver.c b/drivers/media/video/cx18/cx18-driver.c
index 210c68aaae00..49b1c3d7b1a8 100644
--- a/drivers/media/video/cx18/cx18-driver.c
+++ b/drivers/media/video/cx18/cx18-driver.c
@@ -810,7 +810,7 @@ static int __devinit cx18_probe(struct pci_dev *pci_dev,
810 CX18_ERR("Could not register A/V decoder subdevice\n"); 810 CX18_ERR("Could not register A/V decoder subdevice\n");
811 goto free_map; 811 goto free_map;
812 } 812 }
813 cx18_call_hw(cx, CX18_HW_418_AV, core, init, (u32) CX18_AV_INIT_PLLS); 813 cx18_call_hw(cx, CX18_HW_418_AV, core, init, 0);
814 814
815 /* Initialize GPIO Reset Controller to do chip resets during i2c init */ 815 /* Initialize GPIO Reset Controller to do chip resets during i2c init */
816 if (cx->card->hw_all & CX18_HW_GPIO_RESET_CTRL) { 816 if (cx->card->hw_all & CX18_HW_GPIO_RESET_CTRL) {
@@ -1028,7 +1028,7 @@ int cx18_init_on_first_open(struct cx18 *cx)
1028 cx18_vapi(cx, CX18_APU_STOP, 1, CX18_APU_ENCODING_METHOD_MPEG); 1028 cx18_vapi(cx, CX18_APU_STOP, 1, CX18_APU_ENCODING_METHOD_MPEG);
1029 1029
1030 /* Init the A/V decoder, if it hasn't been already */ 1030 /* Init the A/V decoder, if it hasn't been already */
1031 v4l2_subdev_call(cx->sd_av, core, init, (u32) CX18_AV_INIT_NORMAL); 1031 v4l2_subdev_call(cx->sd_av, core, load_fw);
1032 1032
1033 vf.tuner = 0; 1033 vf.tuner = 0;
1034 vf.type = V4L2_TUNER_ANALOG_TV; 1034 vf.type = V4L2_TUNER_ANALOG_TV;