From: Olli Salonen Date: Sun, 13 Jul 2014 13:52:19 +0000 (-0300) Subject: [media] si2157: Move chip initialization to si2157_init X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=b154121c6470b927794ff7ed17355aedfaa073ca;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git [media] si2157: Move chip initialization to si2157_init Move chip initialization related code from si2157_set_params to si2157_init. Signed-off-by: Olli Salonen Reviewed-by: Antti Palosaari Signed-off-by: Antti Palosaari Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c index a4908ee81ab9..a92570f944ea 100644 --- a/drivers/media/tuners/si2157.c +++ b/drivers/media/tuners/si2157.c @@ -80,12 +80,41 @@ err: static int si2157_init(struct dvb_frontend *fe) { struct si2157 *s = fe->tuner_priv; + int ret; + struct si2157_cmd cmd; dev_dbg(&s->client->dev, "%s:\n", __func__); + /* configure? */ + memcpy(cmd.args, "\xc0\x00\x0c\x00\x00\x01\x01\x01\x01\x01\x01\x02\x00\x00\x01", 15); + cmd.wlen = 15; + cmd.rlen = 1; + ret = si2157_cmd_execute(s, &cmd); + if (ret) + goto err; + + /* query chip revision */ + memcpy(cmd.args, "\x02", 1); + cmd.wlen = 1; + cmd.rlen = 13; + ret = si2157_cmd_execute(s, &cmd); + if (ret) + goto err; + + /* reboot the tuner with new firmware? */ + memcpy(cmd.args, "\x01\x01", 2); + cmd.wlen = 2; + cmd.rlen = 1; + ret = si2157_cmd_execute(s, &cmd); + if (ret) + goto err; + s->active = true; return 0; +err: + dev_dbg(&s->client->dev, "%s: failed=%d\n", __func__, ret); + return ret; } static int si2157_sleep(struct dvb_frontend *fe) @@ -128,48 +157,8 @@ static int si2157_set_params(struct dvb_frontend *fe) goto err; } - /* configure? */ - cmd.args[0] = 0xc0; - cmd.args[1] = 0x00; - cmd.args[2] = 0x0c; - cmd.args[3] = 0x00; - cmd.args[4] = 0x00; - cmd.args[5] = 0x01; - cmd.args[6] = 0x01; - cmd.args[7] = 0x01; - cmd.args[8] = 0x01; - cmd.args[9] = 0x01; - cmd.args[10] = 0x01; - cmd.args[11] = 0x02; - cmd.args[12] = 0x00; - cmd.args[13] = 0x00; - cmd.args[14] = 0x01; - cmd.wlen = 15; - cmd.rlen = 1; - ret = si2157_cmd_execute(s, &cmd); - if (ret) - goto err; - - cmd.args[0] = 0x02; - cmd.wlen = 1; - cmd.rlen = 13; - ret = si2157_cmd_execute(s, &cmd); - if (ret) - goto err; - - cmd.args[0] = 0x01; - cmd.args[1] = 0x01; - cmd.wlen = 2; - cmd.rlen = 1; - ret = si2157_cmd_execute(s, &cmd); - if (ret) - goto err; - /* set frequency */ - cmd.args[0] = 0x41; - cmd.args[1] = 0x00; - cmd.args[2] = 0x00; - cmd.args[3] = 0x00; + memcpy(cmd.args, "\x41\x00\x00\x00\x00\x00\x00\x00", 8); cmd.args[4] = (c->frequency >> 0) & 0xff; cmd.args[5] = (c->frequency >> 8) & 0xff; cmd.args[6] = (c->frequency >> 16) & 0xff;