Lines Matching +full:firmware +full:- +full:initialised
1 // SPDX-License-Identifier: GPL-2.0-only
7 * This driver needs external firmware. Please use the command
9 * download/extract it, and then copy it to /usr/lib/hotplug/firmware
10 * or /lib/firmware (depending on configuration of firmware hotplug).
12 #define SP887X_DEFAULT_FIRMWARE "dvb-fe-sp887x.fw"
17 #include <linux/firmware.h>
31 u8 initialised:1; member
42 struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = len }; in i2c_writebytes()
45 if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) { in i2c_writebytes()
47 __func__, state->config->demod_address, err); in i2c_writebytes()
48 return -EREMOTEIO; in i2c_writebytes()
57 struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 4 }; in sp887x_writereg()
60 if ((ret = i2c_transfer(state->i2c, &msg, 1)) != 1) { in sp887x_writereg()
65 (ret == -EREMOTEIO || ret == -EFAULT))) in sp887x_writereg()
81 struct i2c_msg msg[] = {{ .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 2 }, in sp887x_readreg()
82 { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 2 }}; in sp887x_readreg()
84 if ((ret = i2c_transfer(state->i2c, msg, 2)) != 2) { in sp887x_readreg()
86 return -1; in sp887x_readreg()
135 * load firmware and setup MPEG interface...
137 static int sp887x_initial_setup (struct dvb_frontend* fe, const struct firmware *fw) in sp887x_initial_setup()
139 struct sp887x_state* state = fe->demodulator_priv; in sp887x_initial_setup()
142 int fw_size = fw->size; in sp887x_initial_setup()
143 const unsigned char *mem = fw->data + 10; in sp887x_initial_setup()
147 /* ignore the first 10 bytes, then we expect 0x4000 bytes of firmware */ in sp887x_initial_setup()
149 return -ENODEV; in sp887x_initial_setup()
156 printk ("%s: firmware upload... ", __func__); in sp887x_initial_setup()
158 /* setup write pointer to -1 (end of memory) */ in sp887x_initial_setup()
169 if (c > FW_SIZE - i) in sp887x_initial_setup()
170 c = FW_SIZE - i; in sp887x_initial_setup()
216 switch (p->modulation) { in configure_reg0xc05()
229 return -EINVAL; in configure_reg0xc05()
232 switch (p->hierarchy) { in configure_reg0xc05()
248 return -EINVAL; in configure_reg0xc05()
251 switch (p->code_rate_HP) { in configure_reg0xc05()
270 return -EINVAL; in configure_reg0xc05()
309 int freq_offset = actual_freq - p->frequency; in sp887x_correct_offsets()
315 switch (p->bandwidth_hz) { in sp887x_correct_offsets()
328 if (p->inversion == INVERSION_ON) in sp887x_correct_offsets()
329 freq = ifreq - freq_offset; in sp887x_correct_offsets()
335 if (p->inversion == INVERSION_ON) in sp887x_correct_offsets()
336 frequency_shift = -frequency_shift; in sp887x_correct_offsets()
349 struct dtv_frontend_properties *p = &fe->dtv_property_cache; in sp887x_setup_frontend_parameters()
350 struct sp887x_state* state = fe->demodulator_priv; in sp887x_setup_frontend_parameters()
355 if (p->bandwidth_hz != 8000000 && in sp887x_setup_frontend_parameters()
356 p->bandwidth_hz != 7000000 && in sp887x_setup_frontend_parameters()
357 p->bandwidth_hz != 6000000) in sp887x_setup_frontend_parameters()
358 return -EINVAL; in sp887x_setup_frontend_parameters()
366 if (fe->ops.tuner_ops.set_params) { in sp887x_setup_frontend_parameters()
367 fe->ops.tuner_ops.set_params(fe); in sp887x_setup_frontend_parameters()
368 if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0); in sp887x_setup_frontend_parameters()
370 if (fe->ops.tuner_ops.get_frequency) { in sp887x_setup_frontend_parameters()
371 fe->ops.tuner_ops.get_frequency(fe, &actual_freq); in sp887x_setup_frontend_parameters()
372 if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0); in sp887x_setup_frontend_parameters()
374 actual_freq = p->frequency; in sp887x_setup_frontend_parameters()
383 if (p->bandwidth_hz == 6000000) in sp887x_setup_frontend_parameters()
385 else if (p->bandwidth_hz == 7000000) in sp887x_setup_frontend_parameters()
393 if (p->transmission_mode == TRANSMISSION_MODE_2K) in sp887x_setup_frontend_parameters()
400 if (p->bandwidth_hz == 6000000) in sp887x_setup_frontend_parameters()
402 else if (p->bandwidth_hz == 7000000) in sp887x_setup_frontend_parameters()
419 struct sp887x_state* state = fe->demodulator_priv; in sp887x_read_status()
443 steps = -steps; in sp887x_read_status()
453 struct sp887x_state* state = fe->demodulator_priv; in sp887x_read_ber()
467 struct sp887x_state* state = fe->demodulator_priv; in sp887x_read_signal_strength()
478 struct sp887x_state* state = fe->demodulator_priv; in sp887x_read_snr()
488 struct sp887x_state* state = fe->demodulator_priv; in sp887x_read_ucblocks()
499 struct sp887x_state* state = fe->demodulator_priv; in sp887x_i2c_gate_ctrl()
510 struct sp887x_state* state = fe->demodulator_priv; in sp887x_sleep()
520 struct sp887x_state* state = fe->demodulator_priv; in sp887x_init()
521 const struct firmware *fw = NULL; in sp887x_init()
524 if (!state->initialised) { in sp887x_init()
525 /* request the firmware, this will block until someone uploads it */ in sp887x_init()
526 printk("sp887x: waiting for firmware upload (%s)...\n", SP887X_DEFAULT_FIRMWARE); in sp887x_init()
527 ret = state->config->request_firmware(fe, &fw, SP887X_DEFAULT_FIRMWARE); in sp887x_init()
529 printk("sp887x: no firmware upload (timeout or file not found?)\n"); in sp887x_init()
536 printk("sp887x: writing firmware to device failed\n"); in sp887x_init()
539 printk("sp887x: firmware upload complete\n"); in sp887x_init()
540 state->initialised = 1; in sp887x_init()
551 fesettings->min_delay_ms = 350; in sp887x_get_tune_settings()
552 fesettings->step_size = 166666*2; in sp887x_get_tune_settings()
553 fesettings->max_drift = (166666*2)+1; in sp887x_get_tune_settings()
559 struct sp887x_state* state = fe->demodulator_priv; in sp887x_release()
575 state->config = config; in sp887x_attach()
576 state->i2c = i2c; in sp887x_attach()
577 state->initialised = 0; in sp887x_attach()
583 memcpy(&state->frontend.ops, &sp887x_ops, sizeof(struct dvb_frontend_ops)); in sp887x_attach()
584 state->frontend.demodulator_priv = state; in sp887x_attach()
585 return &state->frontend; in sp887x_attach()
595 .name = "Spase SP887x DVB-T",
624 MODULE_DESCRIPTION("Spase sp887x DVB-T demodulator driver");