diff options
-rw-r--r-- | drivers/media/dvb-frontends/drx39xyj/drxj.c | 65 |
1 files changed, 42 insertions, 23 deletions
diff --git a/drivers/media/dvb-frontends/drx39xyj/drxj.c b/drivers/media/dvb-frontends/drx39xyj/drxj.c index 7007e0b507c0..4712399847a3 100644 --- a/drivers/media/dvb-frontends/drx39xyj/drxj.c +++ b/drivers/media/dvb-frontends/drx39xyj/drxj.c | |||
@@ -11315,6 +11315,7 @@ rw_error: | |||
11315 | static int drx_ctrl_u_code(struct drx_demod_instance *demod, | 11315 | static int drx_ctrl_u_code(struct drx_demod_instance *demod, |
11316 | struct drxu_code_info *mc_info, | 11316 | struct drxu_code_info *mc_info, |
11317 | enum drxu_code_action action); | 11317 | enum drxu_code_action action); |
11318 | static int drxj_set_lna_state(struct drx_demod_instance *demod, bool state); | ||
11318 | 11319 | ||
11319 | /** | 11320 | /** |
11320 | * \fn drxj_open() | 11321 | * \fn drxj_open() |
@@ -11527,6 +11528,7 @@ static int drxj_open(struct drx_demod_instance *demod) | |||
11527 | ext_attr->aud_data = drxj_default_aud_data_g; | 11528 | ext_attr->aud_data = drxj_default_aud_data_g; |
11528 | 11529 | ||
11529 | demod->my_common_attr->is_opened = true; | 11530 | demod->my_common_attr->is_opened = true; |
11531 | drxj_set_lna_state(demod, false); | ||
11530 | return 0; | 11532 | return 0; |
11531 | rw_error: | 11533 | rw_error: |
11532 | common_attr->is_opened = false; | 11534 | common_attr->is_opened = false; |
@@ -11890,6 +11892,33 @@ release: | |||
11890 | return rc; | 11892 | return rc; |
11891 | } | 11893 | } |
11892 | 11894 | ||
11895 | /* caller is expeced to check if lna is supported before enabling */ | ||
11896 | static int drxj_set_lna_state(struct drx_demod_instance *demod, bool state) | ||
11897 | { | ||
11898 | struct drxuio_cfg uio_cfg; | ||
11899 | struct drxuio_data uio_data; | ||
11900 | int result; | ||
11901 | |||
11902 | uio_cfg.uio = DRX_UIO1; | ||
11903 | uio_cfg.mode = DRX_UIO_MODE_READWRITE; | ||
11904 | /* Configure user-I/O #3: enable read/write */ | ||
11905 | result = ctrl_set_uio_cfg(demod, &uio_cfg); | ||
11906 | if (result) { | ||
11907 | pr_err("Failed to setup LNA GPIO!\n"); | ||
11908 | return result; | ||
11909 | } | ||
11910 | |||
11911 | uio_data.uio = DRX_UIO1; | ||
11912 | uio_data.value = state; | ||
11913 | result = ctrl_uio_write(demod, &uio_data); | ||
11914 | if (result != 0) { | ||
11915 | pr_err("Failed to %sable LNA!\n", | ||
11916 | state ? "en" : "dis"); | ||
11917 | return result; | ||
11918 | } | ||
11919 | return 0; | ||
11920 | } | ||
11921 | |||
11893 | /* | 11922 | /* |
11894 | * The Linux DVB Driver for Micronas DRX39xx family (drx3933j) | 11923 | * The Linux DVB Driver for Micronas DRX39xx family (drx3933j) |
11895 | * | 11924 | * |
@@ -12180,10 +12209,20 @@ static int drx39xxj_i2c_gate_ctrl(struct dvb_frontend *fe, int enable) | |||
12180 | 12209 | ||
12181 | static int drx39xxj_init(struct dvb_frontend *fe) | 12210 | static int drx39xxj_init(struct dvb_frontend *fe) |
12182 | { | 12211 | { |
12183 | /* Bring the demod out of sleep */ | 12212 | struct drx39xxj_state *state = fe->demodulator_priv; |
12184 | drx39xxj_set_powerstate(fe, 1); | 12213 | struct drx_demod_instance *demod = state->demod; |
12214 | int rc = 0; | ||
12185 | 12215 | ||
12186 | return 0; | 12216 | if (fe->exit == DVB_FE_DEVICE_RESUME) { |
12217 | /* so drxj_open() does what it needs to do */ | ||
12218 | demod->my_common_attr->is_opened = false; | ||
12219 | rc = drxj_open(demod); | ||
12220 | if (rc != 0) | ||
12221 | pr_err("drx39xxj_init(): DRX open failed rc=%d!\n", rc); | ||
12222 | } else | ||
12223 | drx39xxj_set_powerstate(fe, 1); | ||
12224 | |||
12225 | return rc; | ||
12187 | } | 12226 | } |
12188 | 12227 | ||
12189 | static int drx39xxj_set_lna(struct dvb_frontend *fe) | 12228 | static int drx39xxj_set_lna(struct dvb_frontend *fe) |
@@ -12261,8 +12300,6 @@ struct dvb_frontend *drx39xxj_attach(struct i2c_adapter *i2c) | |||
12261 | struct drxj_data *demod_ext_attr = NULL; | 12300 | struct drxj_data *demod_ext_attr = NULL; |
12262 | struct drx_demod_instance *demod = NULL; | 12301 | struct drx_demod_instance *demod = NULL; |
12263 | struct dtv_frontend_properties *p; | 12302 | struct dtv_frontend_properties *p; |
12264 | struct drxuio_cfg uio_cfg; | ||
12265 | struct drxuio_data uio_data; | ||
12266 | int result; | 12303 | int result; |
12267 | 12304 | ||
12268 | /* allocate memory for the internal state */ | 12305 | /* allocate memory for the internal state */ |
@@ -12313,24 +12350,6 @@ struct dvb_frontend *drx39xxj_attach(struct i2c_adapter *i2c) | |||
12313 | goto error; | 12350 | goto error; |
12314 | } | 12351 | } |
12315 | 12352 | ||
12316 | /* Turn off the LNA */ | ||
12317 | uio_cfg.uio = DRX_UIO1; | ||
12318 | uio_cfg.mode = DRX_UIO_MODE_READWRITE; | ||
12319 | /* Configure user-I/O #3: enable read/write */ | ||
12320 | result = ctrl_set_uio_cfg(demod, &uio_cfg); | ||
12321 | if (result) { | ||
12322 | pr_err("Failed to setup LNA GPIO!\n"); | ||
12323 | goto error; | ||
12324 | } | ||
12325 | |||
12326 | uio_data.uio = DRX_UIO1; | ||
12327 | uio_data.value = false; | ||
12328 | result = ctrl_uio_write(demod, &uio_data); | ||
12329 | if (result != 0) { | ||
12330 | pr_err("Failed to disable LNA!\n"); | ||
12331 | goto error; | ||
12332 | } | ||
12333 | |||
12334 | /* create dvb_frontend */ | 12353 | /* create dvb_frontend */ |
12335 | memcpy(&state->frontend.ops, &drx39xxj_ops, | 12354 | memcpy(&state->frontend.ops, &drx39xxj_ops, |
12336 | sizeof(struct dvb_frontend_ops)); | 12355 | sizeof(struct dvb_frontend_ops)); |