Lines Matching +full:x +full:- +full:rc

1 // SPDX-License-Identifier: GPL-2.0-only
6 * Copyright (C) 2009-2010 Mauro Carvalho Chehab
7 * Copyright (C) 2009-2010 Douglas Landgraf <[email protected]>
27 #define rc(args...) do { \ macro
205 int rc; in s921_i2c_writereg() local
207 rc = i2c_transfer(state->i2c, &msg, 1); in s921_i2c_writereg()
208 if (rc != 1) { in s921_i2c_writereg()
209 printk("%s: writereg rcor(rc == %i, reg == 0x%02x, data == 0x%02x)\n", in s921_i2c_writereg()
210 __func__, rc, reg, data); in s921_i2c_writereg()
211 return rc; in s921_i2c_writereg()
220 int i, rc; in s921_i2c_writeregdata() local
223 rc = s921_i2c_writereg(state, i2c_addr, rd[i].reg, rd[i].data); in s921_i2c_writeregdata()
224 if (rc < 0) in s921_i2c_writeregdata()
225 return rc; in s921_i2c_writeregdata()
233 int rc; in s921_i2c_readreg() local
239 rc = i2c_transfer(state->i2c, msg, 2); in s921_i2c_readreg()
241 if (rc != 2) { in s921_i2c_readreg()
242 rc("%s: reg=0x%x (rcor=%d)\n", __func__, reg, rc); in s921_i2c_readreg()
243 return rc; in s921_i2c_readreg()
250 s921_i2c_readreg(state, state->config->demod_address, reg)
252 s921_i2c_writereg(state, state->config->demod_address, reg, val)
254 s921_i2c_writeregdata(state, state->config->demod_address, \
259 struct dtv_frontend_properties *p = &fe->dtv_property_cache; in s921_pll_tune()
260 struct s921_state *state = fe->demodulator_priv; in s921_pll_tune()
261 int band, rc, i; in s921_pll_tune() local
266 dprintk("frequency=%i\n", p->frequency); in s921_pll_tune()
269 if (p->frequency < s921_bandselect[band].freq_low) in s921_pll_tune()
271 band--; in s921_pll_tune()
274 rc("%s: frequency out of range\n", __func__); in s921_pll_tune()
275 return -EINVAL; in s921_pll_tune()
280 offset = ((u64)p->frequency) * 258; in s921_pll_tune()
284 rc = s921_writeregdata(state, s921_prefreq); in s921_pll_tune()
285 if (rc < 0) in s921_pll_tune()
286 return rc; in s921_pll_tune()
288 rc = s921_writereg(state, 0xf2, (f_offset >> 8) & 0xff); in s921_pll_tune()
289 if (rc < 0) in s921_pll_tune()
290 return rc; in s921_pll_tune()
292 rc = s921_writereg(state, 0xf3, f_offset & 0xff); in s921_pll_tune()
293 if (rc < 0) in s921_pll_tune()
294 return rc; in s921_pll_tune()
296 rc = s921_writereg(state, 0xf4, f_switch); in s921_pll_tune()
297 if (rc < 0) in s921_pll_tune()
298 return rc; in s921_pll_tune()
300 rc = s921_writeregdata(state, s921_postfreq); in s921_pll_tune()
301 if (rc < 0) in s921_pll_tune()
302 return rc; in s921_pll_tune()
305 rc = s921_readreg(state, 0x80); in s921_pll_tune()
306 dprintk("status 0x80: %02x\n", rc); in s921_pll_tune()
308 rc = s921_writereg(state, 0x01, 0x40); in s921_pll_tune()
309 if (rc < 0) in s921_pll_tune()
310 return rc; in s921_pll_tune()
312 rc = s921_readreg(state, 0x01); in s921_pll_tune()
313 dprintk("status 0x01: %02x\n", rc); in s921_pll_tune()
315 rc = s921_readreg(state, 0x80); in s921_pll_tune()
316 dprintk("status 0x80: %02x\n", rc); in s921_pll_tune()
318 rc = s921_readreg(state, 0x80); in s921_pll_tune()
319 dprintk("status 0x80: %02x\n", rc); in s921_pll_tune()
321 rc = s921_readreg(state, 0x32); in s921_pll_tune()
322 dprintk("status 0x32: %02x\n", rc); in s921_pll_tune()
331 struct s921_state *state = fe->demodulator_priv; in s921_initfe()
332 int rc; in s921_initfe() local
336 rc = s921_writeregdata(state, s921_init); in s921_initfe()
337 if (rc < 0) in s921_initfe()
338 return rc; in s921_initfe()
345 struct s921_state *state = fe->demodulator_priv; in s921_read_status()
346 int regstatus, rc; in s921_read_status() local
350 rc = s921_readreg(state, 0x81); in s921_read_status()
351 if (rc < 0) in s921_read_status()
352 return rc; in s921_read_status()
354 regstatus = rc << 8; in s921_read_status()
356 rc = s921_readreg(state, 0x82); in s921_read_status()
357 if (rc < 0) in s921_read_status()
358 return rc; in s921_read_status()
360 regstatus |= rc; in s921_read_status()
362 dprintk("status = %04x\n", regstatus); in s921_read_status()
364 /* Full Sync - We don't know what each bit means on regs 0x81/0x82 */ in s921_read_status()
385 struct s921_state *state = fe->demodulator_priv; in s921_read_signal_strength()
386 int rc; in s921_read_signal_strength() local
389 rc = s921_read_status(fe, &status); in s921_read_signal_strength()
390 if (rc < 0) in s921_read_signal_strength()
391 return rc; in s921_read_signal_strength()
395 dprintk("strength = 0x%04x\n", *strength); in s921_read_signal_strength()
397 rc = s921_readreg(state, 0x01); in s921_read_signal_strength()
398 dprintk("status 0x01: %02x\n", rc); in s921_read_signal_strength()
400 rc = s921_readreg(state, 0x80); in s921_read_signal_strength()
401 dprintk("status 0x80: %02x\n", rc); in s921_read_signal_strength()
403 rc = s921_readreg(state, 0x32); in s921_read_signal_strength()
404 dprintk("status 0x32: %02x\n", rc); in s921_read_signal_strength()
411 struct dtv_frontend_properties *p = &fe->dtv_property_cache; in s921_set_frontend()
412 struct s921_state *state = fe->demodulator_priv; in s921_set_frontend()
413 int rc; in s921_set_frontend() local
417 /* FIXME: We don't know how to use non-auto mode */ in s921_set_frontend()
419 rc = s921_pll_tune(fe); in s921_set_frontend()
420 if (rc < 0) in s921_set_frontend()
421 return rc; in s921_set_frontend()
423 state->currentfreq = p->frequency; in s921_set_frontend()
431 struct s921_state *state = fe->demodulator_priv; in s921_get_frontend()
434 p->frequency = state->currentfreq; in s921_get_frontend()
435 p->delivery_system = SYS_ISDBT; in s921_get_frontend()
446 int rc = 0; in s921_tune() local
451 rc = s921_set_frontend(fe); in s921_tune()
456 return rc; in s921_tune()
466 struct s921_state *state = fe->demodulator_priv; in s921_release()
483 rc("Unable to kzalloc\n"); in s921_attach()
488 state->config = config; in s921_attach()
489 state->i2c = i2c; in s921_attach()
492 memcpy(&state->frontend.ops, &s921_ops, in s921_attach()
494 state->frontend.demodulator_priv = state; in s921_attach()
496 return &state->frontend; in s921_attach()