Lines Matching +full:firmware +full:- +full:initialized

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Support for OR51211 (pcHDTV HD-2000) - VSB
14 * This driver needs external firmware. Please use the command
16 * download/extract it, and then copy it to /usr/lib/hotplug/firmware
17 * or /lib/firmware (depending on configuration of firmware hotplug).
19 #define OR51211_DEFAULT_FIRMWARE "dvb-fe-or51211.fw"
24 #include <linux/firmware.h>
51 u8 initialized:1; member
68 if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) { in i2c_writebytes()
70 return -EREMOTEIO; in i2c_writebytes()
85 if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) { in i2c_readbytes()
87 return -EREMOTEIO; in i2c_readbytes()
94 const struct firmware *fw) in or51211_load_firmware()
96 struct or51211_state* state = fe->demodulator_priv; in or51211_load_firmware()
100 dprintk("Firmware is %zu bytes\n", fw->size); in or51211_load_firmware()
106 return -1; in or51211_load_firmware()
110 return -1; in or51211_load_firmware()
113 /* Create firmware buffer */ in or51211_load_firmware()
115 tudata[i] = fw->data[i]; in or51211_load_firmware()
118 tudata[i+337] = fw->data[145+i]; in or51211_load_firmware()
120 state->config->reset(fe); in or51211_load_firmware()
122 if (i2c_writebytes(state,state->config->demod_address,tudata,585)) { in or51211_load_firmware()
124 return -1; in or51211_load_firmware()
128 if (i2c_writebytes(state,state->config->demod_address, in or51211_load_firmware()
129 &fw->data[393],8125)) { in or51211_load_firmware()
131 return -1; in or51211_load_firmware()
135 if (i2c_writebytes(state,state->config->demod_address,run_buf,2)) { in or51211_load_firmware()
137 return -1; in or51211_load_firmware()
142 if (i2c_writebytes(state,state->config->demod_address,run_buf,2)) { in or51211_load_firmware()
144 return -1; in or51211_load_firmware()
154 struct or51211_state* state = fe->demodulator_priv; in or51211_setmode()
157 state->config->setmode(fe, mode); in or51211_setmode()
159 if (i2c_writebytes(state,state->config->demod_address,run_buf,2)) { in or51211_setmode()
161 return -1; in or51211_setmode()
166 if (i2c_writebytes(state,state->config->demod_address,run_buf,2)) { in or51211_setmode()
168 return -1; in or51211_setmode()
180 * normal +/-150kHz Carrier acquisition range in or51211_setmode()
182 if (i2c_writebytes(state,state->config->demod_address,cmd_buf,3)) { in or51211_setmode()
184 return -1; in or51211_setmode()
192 if (i2c_writebytes(state,state->config->demod_address,rec_buf,3)) { in or51211_setmode()
196 if (i2c_readbytes(state,state->config->demod_address,&rec_buf[10],2)) { in or51211_setmode()
198 return -1; in or51211_setmode()
207 struct dtv_frontend_properties *p = &fe->dtv_property_cache; in or51211_set_parameters()
208 struct or51211_state* state = fe->demodulator_priv; in or51211_set_parameters()
211 if (state->current_frequency != p->frequency) { in or51211_set_parameters()
212 if (fe->ops.tuner_ops.set_params) { in or51211_set_parameters()
213 fe->ops.tuner_ops.set_params(fe); in or51211_set_parameters()
214 if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0); in or51211_set_parameters()
221 state->current_frequency = p->frequency; in or51211_set_parameters()
228 struct or51211_state* state = fe->demodulator_priv; in or51211_read_status()
234 if (i2c_writebytes(state,state->config->demod_address,snd_buf,3)) { in or51211_read_status()
236 return -1; in or51211_read_status()
239 if (i2c_readbytes(state,state->config->demod_address,rec_buf,2)) { in or51211_read_status()
241 return -1; in or51211_read_status()
257 8-VSB SNR equation from Oren datasheets
259 For 8-VSB:
262 We re-write the snr equation as:
263 SNR * 2^24 = 10*(c - 2*intlog10(MSE))
264 Where for 8-VSB, c = log10(219037.9454) * 2^24 */
278 return 10*(c - mse); in calculate_snr()
283 struct or51211_state* state = fe->demodulator_priv; in or51211_read_snr()
292 if (i2c_writebytes(state,state->config->demod_address,snd_buf,3)) { in or51211_read_snr()
294 return -1; in or51211_read_snr()
296 if (i2c_readbytes(state,state->config->demod_address,rec_buf,2)) { in or51211_read_snr()
298 return -1; in or51211_read_snr()
301 state->snr = calculate_snr(rec_buf[0], 89599047); in or51211_read_snr()
302 *snr = (state->snr) >> 16; in or51211_read_snr()
305 state->snr >> 24, (((state->snr>>8) & 0xffff) * 100) >> 16); in or51211_read_snr()
315 struct or51211_state* state = (struct or51211_state*)fe->demodulator_priv; in or51211_read_signal_strength()
319 ret = fe->ops.read_snr(fe, &snr); in or51211_read_signal_strength()
322 /* Rather than use the 8.8 value snr, use state->snr which is 8.24 */ in or51211_read_signal_strength()
323 /* scale the range 0 - 35*2^24 into 0 - 65535 */ in or51211_read_signal_strength()
324 if (state->snr >= 8960 * 0x10000) in or51211_read_signal_strength()
327 *strength = state->snr / 8960; in or51211_read_signal_strength()
334 *ber = -ENOSYS; in or51211_read_ber()
340 *ucblocks = -ENOSYS; in or51211_read_ucblocks()
351 struct or51211_state* state = fe->demodulator_priv; in or51211_init()
352 const struct or51211_config* config = state->config; in or51211_init()
353 const struct firmware* fw; in or51211_init()
358 if (!state->initialized) { in or51211_init()
359 /* Request the firmware, this will block until it uploads */ in or51211_init()
360 pr_info("Waiting for firmware upload (%s)...\n", in or51211_init()
362 ret = config->request_firmware(fe, &fw, in or51211_init()
364 pr_info("Got Hotplug firmware\n"); in or51211_init()
366 pr_warn("No firmware uploaded (timeout or file not found?)\n"); in or51211_init()
373 pr_warn("Writing firmware to device failed!\n"); in or51211_init()
376 pr_info("Firmware upload complete.\n"); in or51211_init()
385 * normal +/-150kHz Carrier acquisition range in or51211_init()
387 if (i2c_writebytes(state,state->config->demod_address, in or51211_init()
390 return -1; in or51211_init()
400 if (i2c_writebytes(state,state->config->demod_address, in or51211_init()
403 return -1; in or51211_init()
406 if (i2c_readbytes(state,state->config->demod_address, in or51211_init()
409 return -1; in or51211_init()
417 if (i2c_writebytes(state,state->config->demod_address, in or51211_init()
420 return -1; in or51211_init()
423 if (i2c_readbytes(state,state->config->demod_address, in or51211_init()
426 return -1; in or51211_init()
435 if (i2c_writebytes(state,state->config->demod_address, in or51211_init()
437 pr_warn("Load DVR Error 6 - %d\n", i); in or51211_init()
438 return -1; in or51211_init()
442 if (i2c_readbytes(state,state->config->demod_address, in or51211_init()
444 pr_warn("Load DVR Error 7 - %d\n", i); in or51211_init()
445 return -1; in or51211_init()
449 i--; in or51211_init()
463 if (i2c_writebytes(state,state->config->demod_address, in or51211_init()
466 return -1; in or51211_init()
469 if (i2c_readbytes(state,state->config->demod_address, in or51211_init()
472 return -1; in or51211_init()
474 state->initialized = 1; in or51211_init()
483 fesettings->min_delay_ms = 500; in or51211_get_tune_settings()
484 fesettings->step_size = 0; in or51211_get_tune_settings()
485 fesettings->max_drift = 0; in or51211_get_tune_settings()
491 struct or51211_state* state = fe->demodulator_priv; in or51211_release()
492 state->config->sleep(fe); in or51211_release()
509 state->config = config; in or51211_attach()
510 state->i2c = i2c; in or51211_attach()
511 state->initialized = 0; in or51211_attach()
512 state->current_frequency = 0; in or51211_attach()
515 memcpy(&state->frontend.ops, &or51211_ops, sizeof(struct dvb_frontend_ops)); in or51211_attach()
516 state->frontend.demodulator_priv = state; in or51211_attach()
517 return &state->frontend; in or51211_attach()
550 MODULE_DESCRIPTION("Oren OR51211 VSB [pcHDTV HD-2000] Demodulator Driver");