Skip to content

Commit

Permalink
V4L/DVB (4028): Change dvb_frontend_ops to be a real field instead of…
Browse files Browse the repository at this point in the history
… a pointer field inside dvb_frontend

The dvb_frontend_ops is a pointer inside dvb_frontend. That's why every demod-driver
is having a field of dvb_frontend_ops in its private-state-struct and
using the reference for filling the pointer-field in dvb_frontend.
- It saves at least two lines of code per demod-driver,
- reduces object size (one less dereference per frontend_ops-access),
- be coherent with dvb_tuner_ops,
- makes it a little bit easier for newbies to understand how it works and
- avoids stupid mistakes because you would have to copy the dvb_frontend_ops
  always, before you could assign the static pointer directly, which was
  dangerous.

Signed-off-by: Patrick Boettcher <pb@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
  • Loading branch information
Patrick Boettcher authored and Mauro Carvalho Chehab committed Jun 25, 2006
1 parent 332bed5 commit dea7486
Show file tree
Hide file tree
Showing 61 changed files with 604 additions and 681 deletions.
24 changes: 12 additions & 12 deletions drivers/media/dvb/b2c2/flexcop-fe-tuner.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ static int samsung_tbmu24112_tuner_set_params(struct dvb_frontend* fe, struct dv

if (params->frequency < 1500000) buf[3] |= 0x10;

if (fe->ops->i2c_gate_ctrl)
fe->ops->i2c_gate_ctrl(fe, 1);
if (fe->ops.i2c_gate_ctrl)
fe->ops.i2c_gate_ctrl(fe, 1);
if (i2c_transfer(&fc->i2c_adap, &msg, 1) != 1) {
return -EIO;
}
Expand Down Expand Up @@ -342,8 +342,8 @@ static int skystar23_samsung_tbdu18132_tuner_set_params(struct dvb_frontend* fe,
if (params->frequency < 1550000)
buf[3] |= 0x02;

if (fe->ops->i2c_gate_ctrl)
fe->ops->i2c_gate_ctrl(fe, 1);
if (fe->ops.i2c_gate_ctrl)
fe->ops.i2c_gate_ctrl(fe, 1);
if (i2c_transfer(&fc->i2c_adap, &msg, 1) != 1)
return -EIO;
return 0;
Expand Down Expand Up @@ -389,8 +389,8 @@ int alps_tdee4_stv0297_tuner_set_params (struct dvb_frontend* fe, struct dvb_fro
else if (fep->frequency <= 822000000) buf[3] = 0x08;
else buf[3] = 0x88;

if (fe->ops->i2c_gate_ctrl)
fe->ops->i2c_gate_ctrl(fe, 1);
if (fe->ops.i2c_gate_ctrl)
fe->ops.i2c_gate_ctrl(fe, 1);
deb_tuner("tuner buffer for %d Hz: %x %x %x %x\n",fep->frequency, buf[0],buf[1],buf[2],buf[3]);
ret = fc->i2c_request(fc,FC_WRITE,FC_I2C_PORT_TUNER,0x61,buf[0],&buf[1],3);
deb_tuner("tuner write returned: %d\n",ret);
Expand Down Expand Up @@ -505,7 +505,7 @@ int flexcop_frontend_init(struct flexcop_device *fc)

/* try the sky v2.6 (stv0299/Samsung tbmu24112(sl1935)) */
if ((fc->fe = stv0299_attach(&samsung_tbmu24112_config, &fc->i2c_adap)) != NULL) {
ops = fc->fe->ops;
ops = &fc->fe->ops;

ops->tuner_ops.set_params = samsung_tbmu24112_tuner_set_params;

Expand All @@ -520,7 +520,7 @@ int flexcop_frontend_init(struct flexcop_device *fc)
/* try the air dvb-t (mt352/Samsung tdtc9251dh0(??)) */
if ((fc->fe = mt352_attach(&samsung_tdtc9251dh0_config, &fc->i2c_adap)) != NULL ) {
fc->dev_type = FC_AIR_DVB;
fc->fe->ops->tuner_ops.calc_regs = samsung_tdtc9251dh0_calc_regs;
fc->fe->ops.tuner_ops.calc_regs = samsung_tdtc9251dh0_calc_regs;
info("found the mt352 at i2c address: 0x%02x",samsung_tdtc9251dh0_config.demod_address);
} else
/* try the air atsc 2nd generation (nxt2002) */
Expand All @@ -532,7 +532,7 @@ int flexcop_frontend_init(struct flexcop_device *fc)
/* try the air atsc 3nd generation (lgdt3303) */
if ((fc->fe = lgdt330x_attach(&air2pc_atsc_hd5000_config, &fc->i2c_adap)) != NULL) {
fc->dev_type = FC_AIR_ATSC3;
fc->fe->ops->tuner_ops.set_params = lgdt3303_tuner_set_params;
fc->fe->ops.tuner_ops.set_params = lgdt3303_tuner_set_params;
info("found the lgdt3303 at i2c address: 0x%02x",air2pc_atsc_hd5000_config.demod_address);
} else
/* try the air atsc 1nd generation (bcm3510)/panasonic ct10s */
Expand All @@ -543,12 +543,12 @@ int flexcop_frontend_init(struct flexcop_device *fc)
/* try the cable dvb (stv0297) */
if ((fc->fe = stv0297_attach(&alps_tdee4_stv0297_config, &fc->i2c_adap)) != NULL) {
fc->dev_type = FC_CABLE;
fc->fe->ops->tuner_ops.set_params = alps_tdee4_stv0297_tuner_set_params;
fc->fe->ops.tuner_ops.set_params = alps_tdee4_stv0297_tuner_set_params;
info("found the stv0297 at i2c address: 0x%02x",alps_tdee4_stv0297_config.demod_address);
} else
/* try the sky v2.3 (vp310/Samsung tbdu18132(tsa5059)) */
if ((fc->fe = vp310_mt312_attach(&skystar23_samsung_tbdu18132_config, &fc->i2c_adap)) != NULL) {
ops = fc->fe->ops;
ops = &fc->fe->ops;

ops->tuner_ops.set_params = skystar23_samsung_tbdu18132_tuner_set_params;

Expand All @@ -570,7 +570,7 @@ int flexcop_frontend_init(struct flexcop_device *fc)
} else {
if (dvb_register_frontend(&fc->dvb_adapter, fc->fe)) {
err("frontend registration failed!");
ops = fc->fe->ops;
ops = &fc->fe->ops;
if (ops->release != NULL)
ops->release(fc->fe);
fc->fe = NULL;
Expand Down
10 changes: 4 additions & 6 deletions drivers/media/dvb/bt8xx/dst.c
Original file line number Diff line number Diff line change
Expand Up @@ -1417,24 +1417,22 @@ struct dst_state *dst_attach(struct dst_state *state, struct dvb_adapter *dvb_ad
return NULL;
}
/* determine settings based on type */
/* create dvb_frontend */
switch (state->dst_type) {
case DST_TYPE_IS_TERR:
memcpy(&state->ops, &dst_dvbt_ops, sizeof(struct dvb_frontend_ops));
memcpy(&state->frontend.ops, &dst_dvbt_ops, sizeof(struct dvb_frontend_ops));
break;
case DST_TYPE_IS_CABLE:
memcpy(&state->ops, &dst_dvbc_ops, sizeof(struct dvb_frontend_ops));
memcpy(&state->frontend.ops, &dst_dvbc_ops, sizeof(struct dvb_frontend_ops));
break;
case DST_TYPE_IS_SAT:
memcpy(&state->ops, &dst_dvbs_ops, sizeof(struct dvb_frontend_ops));
memcpy(&state->frontend.ops, &dst_dvbs_ops, sizeof(struct dvb_frontend_ops));
break;
default:
dprintk(verbose, DST_ERROR, 1, "unknown DST type. please report to the LinuxTV.org DVB mailinglist.");
kfree(state);
return NULL;
}

/* create dvb_frontend */
state->frontend.ops = &state->ops;
state->frontend.demodulator_priv = state;

return state; /* Manu (DST is a card not a frontend) */
Expand Down
2 changes: 0 additions & 2 deletions drivers/media/dvb/bt8xx/dst_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ struct dst_state {

struct bt878* bt;

struct dvb_frontend_ops ops;

/* configuration settings */
const struct dst_config* config;

Expand Down
38 changes: 19 additions & 19 deletions drivers/media/dvb/bt8xx/dvb-bt8xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ static int microtune_mt7202dtf_tuner_set_params(struct dvb_frontend* fe, struct
data[2] = ((div >> 10) & 0x60) | cfg;
data[3] = (cpump << 6) | band_select;

if (fe->ops->i2c_gate_ctrl)
fe->ops->i2c_gate_ctrl(fe, 1);
if (fe->ops.i2c_gate_ctrl)
fe->ops.i2c_gate_ctrl(fe, 1);
i2c_transfer(card->i2c_adapter, &msg, 1);
return (div * 166666 - 36000000);
}
Expand Down Expand Up @@ -483,8 +483,8 @@ static int vp3021_alps_tded4_tuner_set_params(struct dvb_frontend* fe, struct dv
else
return -EINVAL;

if (fe->ops->i2c_gate_ctrl)
fe->ops->i2c_gate_ctrl(fe, 1);
if (fe->ops.i2c_gate_ctrl)
fe->ops.i2c_gate_ctrl(fe, 1);
i2c_transfer(card->i2c_adapter, &msg, 1);
return 0;
}
Expand Down Expand Up @@ -607,17 +607,17 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
card->i2c_adapter);

if (card->fe != NULL) {
card->fe->ops->tuner_ops.calc_regs = thomson_dtt7579_tuner_calc_regs;
card->fe->ops->info.frequency_min = 174000000;
card->fe->ops->info.frequency_max = 862000000;
card->fe->ops.tuner_ops.calc_regs = thomson_dtt7579_tuner_calc_regs;
card->fe->ops.info.frequency_min = 174000000;
card->fe->ops.info.frequency_max = 862000000;
}
break;

case BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE:
lgdt330x_reset(card);
card->fe = lgdt330x_attach(&tdvs_tua6034_config, card->i2c_adapter);
if (card->fe != NULL) {
card->fe->ops->tuner_ops.set_params = tdvs_tua6034_tuner_set_params;
card->fe->ops.tuner_ops.set_params = tdvs_tua6034_tuner_set_params;
dprintk ("dvb_bt8xx: lgdt330x detected\n");
}
break;
Expand All @@ -632,7 +632,7 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
digitv_alps_tded4_reset(card);
card->fe = nxt6000_attach(&vp3021_alps_tded4_config, card->i2c_adapter);
if (card->fe != NULL) {
card->fe->ops->tuner_ops.set_params = vp3021_alps_tded4_tuner_set_params;
card->fe->ops.tuner_ops.set_params = vp3021_alps_tded4_tuner_set_params;
dprintk ("dvb_bt8xx: an nxt6000 was detected on your digitv card\n");
break;
}
Expand All @@ -642,24 +642,24 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
card->fe = mt352_attach(&digitv_alps_tded4_config, card->i2c_adapter);

if (card->fe != NULL) {
card->fe->ops->tuner_ops.calc_regs = digitv_alps_tded4_tuner_calc_regs;
card->fe->ops.tuner_ops.calc_regs = digitv_alps_tded4_tuner_calc_regs;
dprintk ("dvb_bt8xx: an mt352 was detected on your digitv card\n");
}
break;

case BTTV_BOARD_AVDVBT_761:
card->fe = sp887x_attach(&microtune_mt7202dtf_config, card->i2c_adapter);
if (card->fe) {
card->fe->ops->tuner_ops.set_params = microtune_mt7202dtf_tuner_set_params;
card->fe->ops.tuner_ops.set_params = microtune_mt7202dtf_tuner_set_params;
}
break;

case BTTV_BOARD_AVDVBT_771:
card->fe = mt352_attach(&advbt771_samsung_tdtc9251dh0_config, card->i2c_adapter);
if (card->fe != NULL) {
card->fe->ops->tuner_ops.calc_regs = advbt771_samsung_tdtc9251dh0_tuner_calc_regs;
card->fe->ops->info.frequency_min = 174000000;
card->fe->ops->info.frequency_max = 862000000;
card->fe->ops.tuner_ops.calc_regs = advbt771_samsung_tdtc9251dh0_tuner_calc_regs;
card->fe->ops.info.frequency_min = 174000000;
card->fe->ops.info.frequency_max = 862000000;
}
break;

Expand Down Expand Up @@ -687,9 +687,9 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
case BTTV_BOARD_PINNACLESAT:
card->fe = cx24110_attach(&pctvsat_config, card->i2c_adapter);
if (card->fe) {
card->fe->ops->tuner_ops.init = pinnsat_tuner_init;
card->fe->ops->tuner_ops.sleep = pinnsat_tuner_sleep;
card->fe->ops->tuner_ops.set_params = cx24108_tuner_set_params;
card->fe->ops.tuner_ops.init = pinnsat_tuner_init;
card->fe->ops.tuner_ops.sleep = pinnsat_tuner_sleep;
card->fe->ops.tuner_ops.set_params = cx24108_tuner_set_params;
}
break;

Expand All @@ -707,8 +707,8 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
else
if (dvb_register_frontend(&card->dvb_adapter, card->fe)) {
printk("dvb-bt8xx: Frontend registration failed!\n");
if (card->fe->ops->release)
card->fe->ops->release(card->fe);
if (card->fe->ops.release)
card->fe->ops.release(card->fe);
card->fe = NULL;
}
}
Expand Down
Loading

0 comments on commit dea7486

Please sign in to comment.