Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 250192
b: refs/heads/master
c: 60f81f1
h: refs/heads/master
v: v3
  • Loading branch information
Florian Mickler authored and Mauro Carvalho Chehab committed May 20, 2011
1 parent 58f6d57 commit 9e8bb82
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 35 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ee52f120b0adc469f5c67815cef79ecdd01cfd14
refs/heads/master: 60f81f12fa63213567b0b40546faa82b8f5d5b0c
69 changes: 35 additions & 34 deletions trunk/drivers/media/dvb/dvb-usb/vp702x-fe.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,13 @@ struct vp702x_fe_state {

static int vp702x_fe_refresh_state(struct vp702x_fe_state *st)
{
struct vp702x_device_state *dst = st->d->priv;
u8 *buf;

if (time_after(jiffies, st->next_status_check)) {
buf = kmalloc(10, GFP_KERNEL);
if (!buf) {
deb_fe("%s: buffer alloc failed\n", __func__);
return -ENOMEM;
}
mutex_lock(&dst->buf_mutex);
buf = dst->buf;

vp702x_usb_in_op(st->d, READ_STATUS, 0, 0, buf, 10);
st->lock = buf[4];

Expand All @@ -58,9 +57,8 @@ static int vp702x_fe_refresh_state(struct vp702x_fe_state *st)
vp702x_usb_in_op(st->d, READ_TUNER_REG_REQ, 0x15, 0, buf, 1);
st->sig = buf[0];


mutex_unlock(&dst->buf_mutex);
st->next_status_check = jiffies + (st->status_check_interval*HZ)/1000;
kfree(buf);
}
return 0;
}
Expand Down Expand Up @@ -141,15 +139,17 @@ static int vp702x_fe_set_frontend(struct dvb_frontend* fe,
struct dvb_frontend_parameters *fep)
{
struct vp702x_fe_state *st = fe->demodulator_priv;
struct vp702x_device_state *dst = st->d->priv;
u32 freq = fep->frequency/1000;
/*CalFrequency*/
/* u16 frequencyRef[16] = { 2, 4, 8, 16, 32, 64, 128, 256, 24, 5, 10, 20, 40, 80, 160, 320 }; */
u64 sr;
u8 *cmd;

cmd = kzalloc(10, GFP_KERNEL);
if (!cmd)
return -ENOMEM;
mutex_lock(&dst->buf_mutex);

cmd = dst->buf;
memset(cmd, 0, 10);

cmd[0] = (freq >> 8) & 0x7f;
cmd[1] = freq & 0xff;
Expand Down Expand Up @@ -192,7 +192,8 @@ static int vp702x_fe_set_frontend(struct dvb_frontend* fe,
else
deb_fe("tuning succeeded.\n");

kfree(cmd);
mutex_unlock(&dst->buf_mutex);

return 0;
}

Expand Down Expand Up @@ -220,21 +221,18 @@ static int vp702x_fe_get_frontend(struct dvb_frontend* fe,
static int vp702x_fe_send_diseqc_msg (struct dvb_frontend* fe,
struct dvb_diseqc_master_cmd *m)
{
int ret;
u8 *cmd;
struct vp702x_fe_state *st = fe->demodulator_priv;

cmd = kzalloc(10, GFP_KERNEL);
if (!cmd)
return -ENOMEM;
struct vp702x_device_state *dst = st->d->priv;

deb_fe("%s\n",__func__);

if (m->msg_len > 4) {
ret = -EINVAL;
goto out;
}
if (m->msg_len > 4)
return -EINVAL;

mutex_lock(&dst->buf_mutex);

cmd = dst->buf;
cmd[1] = SET_DISEQC_CMD;
cmd[2] = m->msg_len;
memcpy(&cmd[3], m->msg, m->msg_len);
Expand All @@ -246,10 +244,10 @@ static int vp702x_fe_send_diseqc_msg (struct dvb_frontend* fe,
deb_fe("diseqc cmd failed.\n");
else
deb_fe("diseqc cmd succeeded.\n");
ret = 0;
out:
kfree(cmd);
return ret;

mutex_unlock(&dst->buf_mutex);

return 0;
}

static int vp702x_fe_send_diseqc_burst (struct dvb_frontend* fe, fe_sec_mini_cmd_t burst)
Expand All @@ -261,14 +259,11 @@ static int vp702x_fe_send_diseqc_burst (struct dvb_frontend* fe, fe_sec_mini_cmd
static int vp702x_fe_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
{
struct vp702x_fe_state *st = fe->demodulator_priv;
struct vp702x_device_state *dst = st->d->priv;
u8 *buf;

deb_fe("%s\n",__func__);

buf = kmalloc(10, GFP_KERNEL);
if (!buf)
return -ENOMEM;

st->tone_mode = tone;

if (tone == SEC_TONE_ON)
Expand All @@ -277,6 +272,10 @@ static int vp702x_fe_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
st->lnb_buf[2] = 0x00;

st->lnb_buf[7] = vp702x_chksum(st->lnb_buf, 0, 7);

mutex_lock(&dst->buf_mutex);

buf = dst->buf;
memcpy(buf, st->lnb_buf, 8);

vp702x_usb_inout_op(st->d, buf, 8, buf, 10, 100);
Expand All @@ -285,21 +284,19 @@ static int vp702x_fe_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
else
deb_fe("set_tone cmd succeeded.\n");

kfree(buf);
mutex_unlock(&dst->buf_mutex);

return 0;
}

static int vp702x_fe_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t
voltage)
{
struct vp702x_fe_state *st = fe->demodulator_priv;
struct vp702x_device_state *dst = st->d->priv;
u8 *buf;
deb_fe("%s\n",__func__);

buf = kmalloc(10, GFP_KERNEL);
if (!buf)
return -ENOMEM;

st->voltage = voltage;

if (voltage != SEC_VOLTAGE_OFF)
Expand All @@ -308,6 +305,10 @@ static int vp702x_fe_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t
st->lnb_buf[4] = 0x00;

st->lnb_buf[7] = vp702x_chksum(st->lnb_buf, 0, 7);

mutex_lock(&dst->buf_mutex);

buf = dst->buf;
memcpy(buf, st->lnb_buf, 8);

vp702x_usb_inout_op(st->d, buf, 8, buf, 10, 100);
Expand All @@ -316,7 +317,7 @@ static int vp702x_fe_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t
else
deb_fe("set_voltage cmd succeeded.\n");

kfree(buf);
mutex_unlock(&dst->buf_mutex);
return 0;
}

Expand Down

0 comments on commit 9e8bb82

Please sign in to comment.