mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-17 01:04:19 +08:00
[media] si2157: add read data support for fw cmd func
We want also read data from firmware. Add support for it. Copied from si2168 driver. Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
This commit is contained in:
parent
88ac8f8606
commit
e6b4380f3e
@ -20,49 +20,51 @@
|
|||||||
static int si2157_cmd_execute(struct si2157 *s, struct si2157_cmd *cmd)
|
static int si2157_cmd_execute(struct si2157 *s, struct si2157_cmd *cmd)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
u8 buf[1];
|
|
||||||
unsigned long timeout;
|
unsigned long timeout;
|
||||||
|
|
||||||
mutex_lock(&s->i2c_mutex);
|
mutex_lock(&s->i2c_mutex);
|
||||||
|
|
||||||
if (cmd->len) {
|
if (cmd->wlen) {
|
||||||
/* write cmd and args for firmware */
|
/* write cmd and args for firmware */
|
||||||
ret = i2c_master_send(s->client, cmd->args, cmd->len);
|
ret = i2c_master_send(s->client, cmd->args, cmd->wlen);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
goto err_mutex_unlock;
|
goto err_mutex_unlock;
|
||||||
} else if (ret != cmd->len) {
|
} else if (ret != cmd->wlen) {
|
||||||
ret = -EREMOTEIO;
|
ret = -EREMOTEIO;
|
||||||
goto err_mutex_unlock;
|
goto err_mutex_unlock;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* wait cmd execution terminate */
|
if (cmd->rlen) {
|
||||||
#define TIMEOUT 80
|
/* wait cmd execution terminate */
|
||||||
timeout = jiffies + msecs_to_jiffies(TIMEOUT);
|
#define TIMEOUT 80
|
||||||
while (!time_after(jiffies, timeout)) {
|
timeout = jiffies + msecs_to_jiffies(TIMEOUT);
|
||||||
ret = i2c_master_recv(s->client, buf, 1);
|
while (!time_after(jiffies, timeout)) {
|
||||||
if (ret < 0) {
|
ret = i2c_master_recv(s->client, cmd->args, cmd->rlen);
|
||||||
goto err_mutex_unlock;
|
if (ret < 0) {
|
||||||
} else if (ret != 1) {
|
goto err_mutex_unlock;
|
||||||
ret = -EREMOTEIO;
|
} else if (ret != cmd->rlen) {
|
||||||
goto err_mutex_unlock;
|
ret = -EREMOTEIO;
|
||||||
|
goto err_mutex_unlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* firmware ready? */
|
||||||
|
if ((cmd->args[0] >> 7) & 0x01)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* firmware ready? */
|
dev_dbg(&s->client->dev, "%s: cmd execution took %d ms\n",
|
||||||
if ((buf[0] >> 7) & 0x01)
|
__func__,
|
||||||
break;
|
jiffies_to_msecs(jiffies) -
|
||||||
|
(jiffies_to_msecs(timeout) - TIMEOUT));
|
||||||
|
|
||||||
|
if (!((cmd->args[0] >> 7) & 0x01)) {
|
||||||
|
ret = -ETIMEDOUT;
|
||||||
|
goto err_mutex_unlock;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dev_dbg(&s->client->dev, "%s: cmd execution took %d ms\n", __func__,
|
ret = 0;
|
||||||
jiffies_to_msecs(jiffies) -
|
|
||||||
(jiffies_to_msecs(timeout) - TIMEOUT));
|
|
||||||
|
|
||||||
if (!(buf[0] >> 7) & 0x01) {
|
|
||||||
ret = -ETIMEDOUT;
|
|
||||||
goto err_mutex_unlock;
|
|
||||||
} else {
|
|
||||||
ret = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
err_mutex_unlock:
|
err_mutex_unlock:
|
||||||
mutex_unlock(&s->i2c_mutex);
|
mutex_unlock(&s->i2c_mutex);
|
||||||
@ -97,7 +99,8 @@ static int si2157_sleep(struct dvb_frontend *fe)
|
|||||||
s->active = false;
|
s->active = false;
|
||||||
|
|
||||||
memcpy(cmd.args, "\x13", 1);
|
memcpy(cmd.args, "\x13", 1);
|
||||||
cmd.len = 1;
|
cmd.wlen = 1;
|
||||||
|
cmd.rlen = 0;
|
||||||
ret = si2157_cmd_execute(s, &cmd);
|
ret = si2157_cmd_execute(s, &cmd);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
@ -141,20 +144,23 @@ static int si2157_set_params(struct dvb_frontend *fe)
|
|||||||
cmd.args[12] = 0x00;
|
cmd.args[12] = 0x00;
|
||||||
cmd.args[13] = 0x00;
|
cmd.args[13] = 0x00;
|
||||||
cmd.args[14] = 0x01;
|
cmd.args[14] = 0x01;
|
||||||
cmd.len = 15;
|
cmd.wlen = 15;
|
||||||
|
cmd.rlen = 1;
|
||||||
ret = si2157_cmd_execute(s, &cmd);
|
ret = si2157_cmd_execute(s, &cmd);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
cmd.args[0] = 0x02;
|
cmd.args[0] = 0x02;
|
||||||
cmd.len = 1;
|
cmd.wlen = 1;
|
||||||
|
cmd.rlen = 13;
|
||||||
ret = si2157_cmd_execute(s, &cmd);
|
ret = si2157_cmd_execute(s, &cmd);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
cmd.args[0] = 0x01;
|
cmd.args[0] = 0x01;
|
||||||
cmd.args[1] = 0x01;
|
cmd.args[1] = 0x01;
|
||||||
cmd.len = 2;
|
cmd.wlen = 2;
|
||||||
|
cmd.rlen = 1;
|
||||||
ret = si2157_cmd_execute(s, &cmd);
|
ret = si2157_cmd_execute(s, &cmd);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
@ -168,7 +174,8 @@ static int si2157_set_params(struct dvb_frontend *fe)
|
|||||||
cmd.args[5] = (c->frequency >> 8) & 0xff;
|
cmd.args[5] = (c->frequency >> 8) & 0xff;
|
||||||
cmd.args[6] = (c->frequency >> 16) & 0xff;
|
cmd.args[6] = (c->frequency >> 16) & 0xff;
|
||||||
cmd.args[7] = (c->frequency >> 24) & 0xff;
|
cmd.args[7] = (c->frequency >> 24) & 0xff;
|
||||||
cmd.len = 8;
|
cmd.wlen = 8;
|
||||||
|
cmd.rlen = 1;
|
||||||
ret = si2157_cmd_execute(s, &cmd);
|
ret = si2157_cmd_execute(s, &cmd);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
@ -212,7 +219,8 @@ static int si2157_probe(struct i2c_client *client,
|
|||||||
mutex_init(&s->i2c_mutex);
|
mutex_init(&s->i2c_mutex);
|
||||||
|
|
||||||
/* check if the tuner is there */
|
/* check if the tuner is there */
|
||||||
cmd.len = 0;
|
cmd.wlen = 0;
|
||||||
|
cmd.rlen = 1;
|
||||||
ret = si2157_cmd_execute(s, &cmd);
|
ret = si2157_cmd_execute(s, &cmd);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
|
@ -31,7 +31,8 @@ struct si2157 {
|
|||||||
#define SI2157_ARGLEN 30
|
#define SI2157_ARGLEN 30
|
||||||
struct si2157_cmd {
|
struct si2157_cmd {
|
||||||
u8 args[SI2157_ARGLEN];
|
u8 args[SI2157_ARGLEN];
|
||||||
unsigned len;
|
unsigned wlen;
|
||||||
|
unsigned rlen;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user