All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] mn88472: load demodulator register defaults
@ 2014-12-07 22:10 Benjamin Larsson
  2014-12-07 22:10 ` [PATCH 2/2] mn88472: fix firmware loading Benjamin Larsson
  2014-12-07 22:25 ` [PATCH 1/2] mn88472: load demodulator register defaults Antti Palosaari
  0 siblings, 2 replies; 9+ messages in thread
From: Benjamin Larsson @ 2014-12-07 22:10 UTC (permalink / raw)
  To: crope; +Cc: Linux Media Mailing List

Signed-off-by: Benjamin Larsson <benjamin@southpole.se>
---
 drivers/staging/media/mn88472/mn88472.c      |  21 +
 drivers/staging/media/mn88472/mn88472_priv.h | 558 +++++++++++++++++++++++++++
 2 files changed, 579 insertions(+)

diff --git a/drivers/staging/media/mn88472/mn88472.c b/drivers/staging/media/mn88472/mn88472.c
index be8a6d5..ffee187 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -272,6 +272,20 @@ err:
 	return ret;
 }
 
+static int mn88472_load_defaults(struct mn88472_dev *dev)
+{
+	int i, ret = 0;
+
+	for (i = 0 ; i < sizeof(mn88472_init_tab)/sizeof(struct idx_num_val)
+		; i++) {
+		ret |= regmap_write(dev->regmap[mn88472_init_tab[i].reg_idx],
+						mn88472_init_tab[i].reg_num,
+						mn88472_init_tab[i].reg_val);
+	}
+
+	return ret;
+}
+
 static int mn88472_init(struct dvb_frontend *fe)
 {
 	struct i2c_client *client = fe->demodulator_priv;
@@ -294,6 +308,13 @@ static int mn88472_init(struct dvb_frontend *fe)
 	if (ret)
 		goto err;
 
+	/* load register defaults */
+	ret = mn88472_load_defaults(dev);
+	if (ret) {
+		dev_err(&client->dev, "register defaults failed\n");
+		goto err;
+	}
+
 	/* request the firmware, this will block and timeout */
 	ret = request_firmware(&fw, fw_file, &client->dev);
 	if (ret) {
diff --git a/drivers/staging/media/mn88472/mn88472_priv.h b/drivers/staging/media/mn88472/mn88472_priv.h
index 9ba8c8b..b77ff1e 100644
--- a/drivers/staging/media/mn88472/mn88472_priv.h
+++ b/drivers/staging/media/mn88472/mn88472_priv.h
@@ -36,4 +36,562 @@ struct mn88472_dev {
 	int ts_clock;
 };
 
+struct idx_num_val {
+	unsigned char reg_idx;
+	unsigned char reg_num;
+	unsigned char reg_val;
+};
+
+struct idx_num_val mn88472_init_tab[] = {
+{ 2, 0x00, 0x66 },
+{ 2, 0x01, 0x00 },
+{ 2, 0x02, 0x01 },
+{ 2, 0x03, 0x03 },
+{ 2, 0x04, 0x00 },
+{ 2, 0x05, 0x00 },
+{ 2, 0x06, 0x00 },
+{ 2, 0x07, 0x00 },
+{ 2, 0x08, 0x00 },
+{ 2, 0x09, 0x00 },
+{ 2, 0x0a, 0x00 },
+{ 2, 0x0b, 0x00 },
+{ 2, 0x0c, 0x00 },
+{ 2, 0x0d, 0x00 },
+{ 2, 0x0e, 0x00 },
+{ 2, 0x0f, 0x00 },
+{ 2, 0x10, 0x3e },
+{ 2, 0x11, 0x70 },
+{ 2, 0x12, 0x64 },
+{ 2, 0x13, 0x8f },
+{ 2, 0x14, 0x80 },
+{ 2, 0x15, 0x00 },
+{ 2, 0x16, 0x08 },
+{ 2, 0x17, 0xee },
+{ 2, 0x18, 0x08 },
+{ 2, 0x19, 0xee },
+{ 2, 0x1a, 0x43 },
+{ 2, 0x1b, 0x00 },
+{ 2, 0x1c, 0x74 },
+{ 2, 0x1d, 0xe4 },
+{ 2, 0x1e, 0x26 },
+{ 2, 0x1f, 0x4f },
+{ 2, 0x20, 0x72 },
+{ 2, 0x21, 0x22 },
+{ 2, 0x22, 0x22 },
+{ 2, 0x23, 0x01 },
+{ 2, 0x24, 0x00 },
+{ 2, 0x25, 0x12 },
+{ 2, 0x26, 0x00 },
+{ 2, 0x27, 0x00 },
+{ 2, 0x28, 0x80 },
+{ 2, 0x29, 0x0c },
+{ 2, 0x2a, 0xf4 },
+{ 2, 0x2b, 0x13 },
+{ 2, 0x2c, 0x00 },
+{ 2, 0x2d, 0x20 },
+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
+{ 1, 0xf6, 0x05 },
+{ 2, 0xfb, 0x03 },
+{ 1, 0xfc, 0x00 },
+{ 1, 0xfd, 0x00 },
+{ 1, 0xfe, 0x00 },
+{ 1, 0xff, 0x02 },
+};
+
 #endif
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/2] mn88472: fix firmware loading
  2014-12-07 22:10 [PATCH 1/2] mn88472: load demodulator register defaults Benjamin Larsson
@ 2014-12-07 22:10 ` Benjamin Larsson
  2014-12-07 22:36   ` Antti Palosaari
  2014-12-07 22:25 ` [PATCH 1/2] mn88472: load demodulator register defaults Antti Palosaari
  1 sibling, 1 reply; 9+ messages in thread
From: Benjamin Larsson @ 2014-12-07 22:10 UTC (permalink / raw)
  To: crope; +Cc: Linux Media Mailing List

The firmware must be loaded one byte at a time via the 0xf6 register.

Signed-off-by: Benjamin Larsson <benjamin@southpole.se>
---
 drivers/staging/media/mn88472/mn88472.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/media/mn88472/mn88472.c b/drivers/staging/media/mn88472/mn88472.c
index ffee187..ba1bc8d 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -290,7 +290,7 @@ static int mn88472_init(struct dvb_frontend *fe)
 {
 	struct i2c_client *client = fe->demodulator_priv;
 	struct mn88472_dev *dev = i2c_get_clientdata(client);
-	int ret, len, remaining;
+	int ret, i;
 	const struct firmware *fw = NULL;
 	u8 *fw_file = MN88472_FIRMWARE;
 
@@ -330,19 +330,12 @@ static int mn88472_init(struct dvb_frontend *fe)
 	if (ret)
 		goto err;
 
-	for (remaining = fw->size; remaining > 0;
-			remaining -= (dev->i2c_wr_max - 1)) {
-		len = remaining;
-		if (len > (dev->i2c_wr_max - 1))
-			len = (dev->i2c_wr_max - 1);
-
-		ret = regmap_bulk_write(dev->regmap[0], 0xf6,
-				&fw->data[fw->size - remaining], len);
-		if (ret) {
-			dev_err(&client->dev,
-					"firmware download failed=%d\n", ret);
-			goto err;
-		}
+	for (i = 0 ; i < fw->size ; i++)
+		ret |= regmap_write(dev->regmap[0], 0xf6, fw->data[i]);
+	if (ret) {
+		dev_err(&client->dev,
+				"firmware download failed=%d\n", ret);
+		goto err;
 	}
 
 	ret = regmap_write(dev->regmap[0], 0xf5, 0x00);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] mn88472: load demodulator register defaults
  2014-12-07 22:10 [PATCH 1/2] mn88472: load demodulator register defaults Benjamin Larsson
  2014-12-07 22:10 ` [PATCH 2/2] mn88472: fix firmware loading Benjamin Larsson
@ 2014-12-07 22:25 ` Antti Palosaari
  1 sibling, 0 replies; 9+ messages in thread
From: Antti Palosaari @ 2014-12-07 22:25 UTC (permalink / raw)
  To: Benjamin Larsson; +Cc: Linux Media Mailing List

Moikka!
I don't like that at *all*. It is totally bad idea to write 550 
registers to "default" and even more bad it is done as single register 
at once. It is huge amount of I/O traffic in a situation device has 
problems with I/O. Did you even compared are those registers already 
same than POR (power on reset)?

550 registers means basically writing every single register of that 
chip. It is hard to imagine chip designers has made that bad mistake and 
set wrong default value for every register.

There is regmap already used, you likely need to learn what are POR 
default values and which registers need to be changed. Then teach all 
that info to RegMap and it will do shadow registering (to reduce I/O).

regard
Antti



On 12/08/2014 12:10 AM, Benjamin Larsson wrote:
> Signed-off-by: Benjamin Larsson <benjamin@southpole.se>
> ---
>   drivers/staging/media/mn88472/mn88472.c      |  21 +
>   drivers/staging/media/mn88472/mn88472_priv.h | 558 +++++++++++++++++++++++++++
>   2 files changed, 579 insertions(+)
>
> diff --git a/drivers/staging/media/mn88472/mn88472.c b/drivers/staging/media/mn88472/mn88472.c
> index be8a6d5..ffee187 100644
> --- a/drivers/staging/media/mn88472/mn88472.c
> +++ b/drivers/staging/media/mn88472/mn88472.c
> @@ -272,6 +272,20 @@ err:
>   	return ret;
>   }
>
> +static int mn88472_load_defaults(struct mn88472_dev *dev)
> +{
> +	int i, ret = 0;
> +
> +	for (i = 0 ; i < sizeof(mn88472_init_tab)/sizeof(struct idx_num_val)
> +		; i++) {
> +		ret |= regmap_write(dev->regmap[mn88472_init_tab[i].reg_idx],
> +						mn88472_init_tab[i].reg_num,
> +						mn88472_init_tab[i].reg_val);
> +	}
> +
> +	return ret;
> +}
> +
>   static int mn88472_init(struct dvb_frontend *fe)
>   {
>   	struct i2c_client *client = fe->demodulator_priv;
> @@ -294,6 +308,13 @@ static int mn88472_init(struct dvb_frontend *fe)
>   	if (ret)
>   		goto err;
>
> +	/* load register defaults */
> +	ret = mn88472_load_defaults(dev);
> +	if (ret) {
> +		dev_err(&client->dev, "register defaults failed\n");
> +		goto err;
> +	}
> +
>   	/* request the firmware, this will block and timeout */
>   	ret = request_firmware(&fw, fw_file, &client->dev);
>   	if (ret) {
> diff --git a/drivers/staging/media/mn88472/mn88472_priv.h b/drivers/staging/media/mn88472/mn88472_priv.h
> index 9ba8c8b..b77ff1e 100644
> --- a/drivers/staging/media/mn88472/mn88472_priv.h
> +++ b/drivers/staging/media/mn88472/mn88472_priv.h
> @@ -36,4 +36,562 @@ struct mn88472_dev {
>   	int ts_clock;
>   };
>
> +struct idx_num_val {
> +	unsigned char reg_idx;
> +	unsigned char reg_num;
> +	unsigned char reg_val;
> +};
> +
> +struct idx_num_val mn88472_init_tab[] = {
> +{ 2, 0x00, 0x66 },
> +{ 2, 0x01, 0x00 },
> +{ 2, 0x02, 0x01 },
> +{ 2, 0x03, 0x03 },
> +{ 2, 0x04, 0x00 },
> +{ 2, 0x05, 0x00 },
> +{ 2, 0x06, 0x00 },
> +{ 2, 0x07, 0x00 },
> +{ 2, 0x08, 0x00 },
> +{ 2, 0x09, 0x00 },
> +{ 2, 0x0a, 0x00 },
> +{ 2, 0x0b, 0x00 },
> +{ 2, 0x0c, 0x00 },
> +{ 2, 0x0d, 0x00 },
> +{ 2, 0x0e, 0x00 },
> +{ 2, 0x0f, 0x00 },
> +{ 2, 0x10, 0x3e },
> +{ 2, 0x11, 0x70 },
> +{ 2, 0x12, 0x64 },
> +{ 2, 0x13, 0x8f },
> +{ 2, 0x14, 0x80 },
> +{ 2, 0x15, 0x00 },
> +{ 2, 0x16, 0x08 },
> +{ 2, 0x17, 0xee },
> +{ 2, 0x18, 0x08 },
> +{ 2, 0x19, 0xee },
> +{ 2, 0x1a, 0x43 },
> +{ 2, 0x1b, 0x00 },
> +{ 2, 0x1c, 0x74 },
> +{ 2, 0x1d, 0xe4 },
> +{ 2, 0x1e, 0x26 },
> +{ 2, 0x1f, 0x4f },
> +{ 2, 0x20, 0x72 },
> +{ 2, 0x21, 0x22 },
> +{ 2, 0x22, 0x22 },
> +{ 2, 0x23, 0x01 },
> +{ 2, 0x24, 0x00 },
> +{ 2, 0x25, 0x12 },
> +{ 2, 0x26, 0x00 },
> +{ 2, 0x27, 0x00 },
> +{ 2, 0x28, 0x80 },
> +{ 2, 0x29, 0x0c },
> +{ 2, 0x2a, 0xf4 },
> +{ 2, 0x2b, 0x13 },
> +{ 2, 0x2c, 0x00 },
> +{ 2, 0x2d, 0x20 },
> +{ 2, 0x2e, 0x88 },
> +{ 2, 0x2f, 0x00 },
> +{ 2, 0x30, 0x80 },
> +{ 2, 0x31, 0x80 },
> +{ 2, 0x32, 0x00 },
> +{ 2, 0x33, 0x00 },
> +{ 2, 0x34, 0x00 },
> +{ 2, 0x35, 0x00 },
> +{ 2, 0x36, 0x00 },
> +{ 2, 0x37, 0x00 },
> +{ 2, 0x38, 0xca },
> +{ 2, 0x39, 0x03 },
> +{ 2, 0x3a, 0x02 },
> +{ 2, 0x3b, 0x55 },
> +{ 2, 0x3c, 0xd7 },
> +{ 2, 0x3d, 0x00 },
> +{ 2, 0x3e, 0x00 },
> +{ 2, 0x3f, 0x22 },
> +{ 2, 0x40, 0x00 },
> +{ 2, 0x41, 0x38 },
> +{ 2, 0x42, 0x22 },
> +{ 2, 0x43, 0x00 },
> +{ 2, 0x44, 0x38 },
> +{ 2, 0x45, 0xd3 },
> +{ 2, 0x46, 0x10 },
> +{ 2, 0x47, 0xb5 },
> +{ 2, 0x48, 0xa1 },
> +{ 2, 0x49, 0x00 },
> +{ 2, 0x4a, 0xd3 },
> +{ 2, 0x4b, 0x07 },
> +{ 2, 0x4c, 0x64 },
> +{ 2, 0x4d, 0x0d },
> +{ 2, 0x4e, 0x00 },
> +{ 2, 0x4f, 0x05 },
> +{ 2, 0x50, 0x00 },
> +{ 2, 0x51, 0x55 },
> +{ 2, 0x52, 0x20 },
> +{ 2, 0x53, 0x00 },
> +{ 2, 0x54, 0x24 },
> +{ 2, 0x55, 0x64 },
> +{ 2, 0x56, 0x44 },
> +{ 2, 0x57, 0x33 },
> +{ 2, 0x58, 0x1f },
> +{ 2, 0x59, 0x00 },
> +{ 2, 0x5a, 0x5a },
> +{ 2, 0x5b, 0x03 },
> +{ 2, 0x5c, 0xc0 },
> +{ 2, 0x5d, 0x00 },
> +{ 2, 0x5e, 0x00 },
> +{ 2, 0x5f, 0x03 },
> +{ 2, 0x60, 0x00 },
> +{ 2, 0x61, 0x00 },
> +{ 2, 0x62, 0x11 },
> +{ 2, 0x63, 0x40 },
> +{ 2, 0x64, 0x84 },
> +{ 2, 0x65, 0x04 },
> +{ 2, 0x66, 0x0c },
> +{ 2, 0x67, 0x00 },
> +{ 2, 0x68, 0x08 },
> +{ 2, 0x69, 0x00 },
> +{ 2, 0x6a, 0x00 },
> +{ 2, 0x6b, 0x12 },
> +{ 2, 0x6c, 0x21 },
> +{ 2, 0x6d, 0x10 },
> +{ 2, 0x6e, 0x01 },
> +{ 2, 0x6f, 0x00 },
> +{ 2, 0x70, 0x00 },
> +{ 2, 0x71, 0x00 },
> +{ 2, 0x72, 0xe8 },
> +{ 2, 0x73, 0x48 },
> +{ 2, 0x74, 0x40 },
> +{ 2, 0x75, 0x00 },
> +{ 2, 0x76, 0x1d },
> +{ 2, 0x77, 0x19 },
> +{ 2, 0x78, 0x1d },
> +{ 2, 0x79, 0x19 },
> +{ 2, 0x7a, 0x66 },
> +{ 2, 0x7b, 0x8c },
> +{ 2, 0x7c, 0x9f },
> +{ 2, 0x7d, 0x08 },
> +{ 2, 0x7e, 0x00 },
> +{ 2, 0x7f, 0x00 },
> +{ 2, 0x80, 0x00 },
> +{ 2, 0x81, 0x00 },
> +{ 2, 0x83, 0x00 },
> +{ 2, 0x84, 0x00 },
> +{ 2, 0x85, 0x00 },
> +{ 2, 0x86, 0x00 },
> +{ 2, 0x87, 0x00 },
> +{ 2, 0x88, 0x00 },
> +{ 2, 0x89, 0x00 },
> +{ 2, 0x8a, 0x20 },
> +{ 2, 0x8b, 0x49 },
> +{ 2, 0x8c, 0x00 },
> +{ 2, 0xc4, 0x00 },
> +{ 2, 0xc5, 0x00 },
> +{ 2, 0xc6, 0x00 },
> +{ 2, 0xc7, 0x87 },
> +{ 2, 0xc8, 0x40 },
> +{ 2, 0xc9, 0x30 },
> +{ 2, 0xca, 0x06 },
> +{ 2, 0xcb, 0x02 },
> +{ 2, 0xcc, 0x00 },
> +{ 2, 0xcd, 0x3b },
> +{ 2, 0xce, 0x00 },
> +{ 2, 0xcf, 0x00 },
> +{ 2, 0xd0, 0x00 },
> +{ 2, 0xd1, 0x00 },
> +{ 2, 0xd2, 0x00 },
> +{ 2, 0xd3, 0x40 },
> +{ 2, 0xd4, 0x00 },
> +{ 2, 0xd5, 0xf0 },
> +{ 2, 0xd6, 0x02 },
> +{ 2, 0xd7, 0x02 },
> +{ 2, 0xd8, 0x01 },
> +{ 2, 0xd9, 0x00 },
> +{ 2, 0xda, 0x00 },
> +{ 2, 0xdb, 0x00 },
> +{ 2, 0xdc, 0x00 },
> +{ 2, 0xdd, 0x00 },
> +{ 2, 0xde, 0x00 },
> +{ 2, 0xdf, 0x00 },
> +{ 2, 0xe0, 0x00 },
> +{ 2, 0xe1, 0x00 },
> +{ 2, 0xe2, 0x00 },
> +{ 2, 0xe3, 0x00 },
> +{ 2, 0xe4, 0x00 },
> +{ 2, 0xe5, 0x00 },
> +{ 2, 0xe6, 0x00 },
> +{ 2, 0xe7, 0x00 },
> +{ 2, 0xe9, 0x00 },
> +{ 2, 0xea, 0x00 },
> +{ 2, 0xeb, 0x00 },
> +{ 2, 0xec, 0xd3 },
> +{ 2, 0xed, 0x31 },
> +{ 2, 0xee, 0x00 },
> +{ 2, 0xef, 0x00 },
> +{ 2, 0xf0, 0x00 },
> +{ 2, 0xf1, 0x00 },
> +{ 2, 0xf2, 0x00 },
> +{ 2, 0xf3, 0x00 },
> +{ 2, 0xf4, 0x00 },
> +{ 2, 0xf5, 0x00 },
> +{ 2, 0xf6, 0x00 },
> +{ 2, 0xf8, 0x9f },
> +{ 2, 0xf9, 0xd4 },
> +{ 2, 0xfa, 0x00 },
> +{ 2, 0xfb, 0x03 },
> +{ 2, 0xfc, 0x00 },
> +{ 2, 0xfd, 0x00 },
> +{ 2, 0xfe, 0x00 },
> +{ 2, 0xff, 0x02 },
> +{ 0, 0x00, 0xba },
> +{ 0, 0x01, 0x13 },
> +{ 0, 0x02, 0x80 },
> +{ 0, 0x03, 0xba },
> +{ 0, 0x04, 0x91 },
> +{ 0, 0x05, 0x40 },
> +{ 0, 0x06, 0xe7 },
> +{ 0, 0x07, 0x26 },
> +{ 0, 0x08, 0xff },
> +{ 0, 0x09, 0x1b },
> +{ 0, 0x0a, 0x09 },
> +{ 0, 0x0b, 0x08 },
> +{ 0, 0x0c, 0x04 },
> +{ 0, 0x0d, 0x2d },
> +{ 0, 0x0e, 0x09 },
> +{ 0, 0x0f, 0x00 },
> +{ 0, 0x10, 0x10 },
> +{ 0, 0x11, 0x1f },
> +{ 0, 0x12, 0x08 },
> +{ 0, 0x13, 0x00 },
> +{ 0, 0x14, 0x00 },
> +{ 0, 0x15, 0x03 },
> +{ 0, 0x16, 0x00 },
> +{ 0, 0x17, 0x00 },
> +{ 0, 0x18, 0x00 },
> +{ 0, 0x19, 0xb0 },
> +{ 0, 0x1a, 0x00 },
> +{ 0, 0x1b, 0x00 },
> +{ 0, 0x1c, 0x00 },
> +{ 0, 0x1d, 0xe0 },
> +{ 0, 0x1e, 0x6c },
> +{ 0, 0x1f, 0x33 },
> +{ 0, 0x20, 0x4a },
> +{ 0, 0x21, 0x03 },
> +{ 0, 0x22, 0x00 },
> +{ 0, 0x23, 0x01 },
> +{ 0, 0x24, 0x05 },
> +{ 0, 0x25, 0x96 },
> +{ 0, 0x26, 0x43 },
> +{ 0, 0x27, 0x00 },
> +{ 0, 0x28, 0x01 },
> +{ 0, 0x29, 0x15 },
> +{ 0, 0x2a, 0xa2 },
> +{ 0, 0x2b, 0xc3 },
> +{ 0, 0x2c, 0xf5 },
> +{ 0, 0x2d, 0x22 },
> +{ 0, 0x2e, 0x87 },
> +{ 0, 0x2f, 0xd3 },
> +{ 0, 0x30, 0x00 },
> +{ 0, 0x31, 0x55 },
> +{ 0, 0x32, 0x33 },
> +{ 0, 0x33, 0x61 },
> +{ 0, 0x34, 0x22 },
> +{ 0, 0x35, 0x01 },
> +{ 0, 0x36, 0x02 },
> +{ 0, 0x37, 0x40 },
> +{ 0, 0x38, 0x40 },
> +{ 0, 0x39, 0x46 },
> +{ 0, 0x3a, 0x25 },
> +{ 0, 0x3b, 0x04 },
> +{ 0, 0x3c, 0x00 },
> +{ 0, 0x3d, 0x04 },
> +{ 0, 0x3e, 0x00 },
> +{ 0, 0x3f, 0x00 },
> +{ 0, 0x40, 0x3b },
> +{ 0, 0x41, 0x20 },
> +{ 0, 0x42, 0x00 },
> +{ 0, 0x43, 0x3f },
> +{ 0, 0x44, 0x1f },
> +{ 0, 0x45, 0x05 },
> +{ 0, 0x46, 0x00 },
> +{ 0, 0x47, 0x00 },
> +{ 0, 0x48, 0x05 },
> +{ 0, 0x49, 0xf0 },
> +{ 0, 0x4a, 0x00 },
> +{ 0, 0x4b, 0x00 },
> +{ 0, 0x4c, 0x1f },
> +{ 0, 0x4d, 0x0f },
> +{ 0, 0x4e, 0x39 },
> +{ 0, 0x4f, 0x03 },
> +{ 0, 0x50, 0xf8 },
> +{ 0, 0x51, 0xf4 },
> +{ 0, 0x52, 0x08 },
> +{ 0, 0x53, 0xf8 },
> +{ 0, 0x54, 0xea },
> +{ 0, 0x55, 0xf0 },
> +{ 0, 0x56, 0x04 },
> +{ 0, 0x57, 0x20 },
> +{ 0, 0x58, 0x12 },
> +{ 0, 0x59, 0x12 },
> +{ 0, 0x5a, 0x02 },
> +{ 0, 0x5b, 0x20 },
> +{ 0, 0x5c, 0x1a },
> +{ 0, 0x5d, 0x08 },
> +{ 0, 0x5e, 0xad },
> +{ 0, 0x5f, 0x33 },
> +{ 0, 0x60, 0x95 },
> +{ 0, 0x61, 0x8f },
> +{ 0, 0x62, 0x80 },
> +{ 0, 0x63, 0x00 },
> +{ 0, 0x64, 0x76 },
> +{ 0, 0x65, 0x54 },
> +{ 0, 0x66, 0x87 },
> +{ 0, 0x67, 0x65 },
> +{ 0, 0x68, 0x66 },
> +{ 0, 0x69, 0x54 },
> +{ 0, 0x6a, 0x4a },
> +{ 0, 0x6b, 0x86 },
> +{ 0, 0x6c, 0x13 },
> +{ 0, 0x6d, 0x31 },
> +{ 0, 0x6e, 0x2d },
> +{ 0, 0x6f, 0x07 },
> +{ 0, 0x70, 0x00 },
> +{ 0, 0x71, 0x40 },
> +{ 0, 0x72, 0x00 },
> +{ 0, 0x73, 0x00 },
> +{ 0, 0x74, 0x00 },
> +{ 0, 0x75, 0x10 },
> +{ 0, 0x76, 0x0c },
> +{ 0, 0x77, 0x0c },
> +{ 0, 0x78, 0x59 },
> +{ 0, 0x79, 0x00 },
> +{ 0, 0x7a, 0x00 },
> +{ 0, 0x7b, 0x00 },
> +{ 0, 0x7c, 0x00 },
> +{ 0, 0x7d, 0x05 },
> +{ 0, 0x88, 0x1e },
> +{ 0, 0x89, 0x49 },
> +{ 0, 0x8a, 0x31 },
> +{ 0, 0x8b, 0x1a },
> +{ 0, 0x8c, 0x2c },
> +{ 0, 0x8d, 0x3f },
> +{ 0, 0x8e, 0x7f },
> +{ 0, 0x8f, 0x07 },
> +{ 0, 0xa5, 0x00 },
> +{ 0, 0xa6, 0x00 },
> +{ 0, 0xa9, 0x00 },
> +{ 0, 0xaa, 0x00 },
> +{ 0, 0xab, 0x00 },
> +{ 0, 0xae, 0x00 },
> +{ 0, 0xaf, 0x00 },
> +{ 0, 0xb0, 0x0a },
> +{ 0, 0xb1, 0x7a },
> +{ 0, 0xb2, 0x40 },
> +{ 0, 0xb3, 0x5c },
> +{ 0, 0xb4, 0xf6 },
> +{ 0, 0xb5, 0x31 },
> +{ 0, 0xb6, 0xc0 },
> +{ 0, 0xb7, 0xff },
> +{ 0, 0xb8, 0x88 },
> +{ 0, 0xb9, 0xff },
> +{ 0, 0xba, 0xaa },
> +{ 0, 0xbb, 0x00 },
> +{ 0, 0xbc, 0x08 },
> +{ 0, 0xbd, 0x03 },
> +{ 0, 0xbe, 0x00 },
> +{ 0, 0xbf, 0x00 },
> +{ 0, 0xc0, 0xbf },
> +{ 0, 0xc1, 0x00 },
> +{ 0, 0xc2, 0x00 },
> +{ 0, 0xc3, 0xff },
> +{ 0, 0xc4, 0x20 },
> +{ 0, 0xc5, 0x80 },
> +{ 0, 0xc6, 0xff },
> +{ 0, 0xc7, 0xff },
> +{ 0, 0xc8, 0xff },
> +{ 0, 0xc9, 0xe0 },
> +{ 0, 0xca, 0x80 },
> +{ 0, 0xcb, 0x00 },
> +{ 0, 0xcc, 0x00 },
> +{ 0, 0xcd, 0x01 },
> +{ 0, 0xce, 0x00 },
> +{ 0, 0xcf, 0x54 },
> +{ 0, 0xd0, 0x23 },
> +{ 0, 0xd1, 0x47 },
> +{ 0, 0xd2, 0x01 },
> +{ 0, 0xd3, 0x00 },
> +{ 0, 0xd4, 0x09 },
> +{ 0, 0xd5, 0x47 },
> +{ 0, 0xd6, 0x46 },
> +{ 0, 0xd7, 0x00 },
> +{ 0, 0xd8, 0x00 },
> +{ 0, 0xd9, 0xe1 },
> +{ 0, 0xda, 0x03 },
> +{ 0, 0xdb, 0x08 },
> +{ 0, 0xdc, 0xb8 },
> +{ 0, 0xdd, 0x08 },
> +{ 0, 0xde, 0x0c },
> +{ 0, 0xdf, 0x90 },
> +{ 0, 0xe6, 0x00 },
> +{ 0, 0xe7, 0x00 },
> +{ 0, 0xe8, 0x00 },
> +{ 0, 0xec, 0x00 },
> +{ 0, 0xed, 0x00 },
> +{ 0, 0xee, 0x00 },
> +{ 2, 0xfb, 0x03 },
> +{ 0, 0xf0, 0x00 },
> +{ 0, 0xf1, 0x00 },
> +{ 0, 0xf2, 0x00 },
> +{ 0, 0xf3, 0x00 },
> +{ 0, 0xf4, 0x00 },
> +{ 0, 0xf5, 0x01 },
> +{ 0, 0xf7, 0x00 },
> +{ 0, 0xf8, 0x00 },
> +{ 0, 0xf9, 0x07 },
> +{ 0, 0xfa, 0xff },
> +{ 0, 0xfb, 0x00 },
> +{ 0, 0xfc, 0x00 },
> +{ 0, 0xfd, 0x30 },
> +{ 0, 0xfe, 0x00 },
> +{ 0, 0xff, 0x02 },
> +{ 1, 0x00, 0xb0 },
> +{ 1, 0x01, 0x00 },
> +{ 1, 0x02, 0x11 },
> +{ 1, 0x03, 0x18 },
> +{ 1, 0x04, 0x04 },
> +{ 1, 0x05, 0xe0 },
> +{ 1, 0x06, 0x5f },
> +{ 1, 0x07, 0x27 },
> +{ 1, 0x08, 0x30 },
> +{ 1, 0x09, 0xff },
> +{ 1, 0x0a, 0xc0 },
> +{ 1, 0x0b, 0xaa },
> +{ 1, 0x0c, 0xbb },
> +{ 1, 0x0d, 0xee },
> +{ 1, 0x0e, 0xaa },
> +{ 1, 0x0f, 0xaa },
> +{ 1, 0x10, 0x0d },
> +{ 1, 0x11, 0xab },
> +{ 1, 0x12, 0x0b },
> +{ 1, 0x13, 0x3c },
> +{ 1, 0x14, 0x18 },
> +{ 1, 0x15, 0xd9 },
> +{ 1, 0x16, 0x51 },
> +{ 1, 0x17, 0xec },
> +{ 1, 0x18, 0x00 },
> +{ 1, 0x19, 0xbe },
> +{ 1, 0x1a, 0xd6 },
> +{ 1, 0x1b, 0x1c },
> +{ 1, 0x1c, 0x0b },
> +{ 1, 0x1d, 0x3c },
> +{ 1, 0x1e, 0x29 },
> +{ 1, 0x1f, 0x00 },
> +{ 1, 0x20, 0x00 },
> +{ 1, 0x21, 0x00 },
> +{ 1, 0x22, 0xa0 },
> +{ 1, 0x23, 0x94 },
> +{ 1, 0x24, 0xaf },
> +{ 1, 0x25, 0x01 },
> +{ 1, 0x26, 0x00 },
> +{ 1, 0x27, 0x00 },
> +{ 1, 0x28, 0x00 },
> +{ 1, 0x29, 0x00 },
> +{ 1, 0x2a, 0x00 },
> +{ 1, 0x2b, 0x00 },
> +{ 1, 0x2c, 0x00 },
> +{ 1, 0x2d, 0x00 },
> +{ 1, 0x2e, 0x00 },
> +{ 1, 0x2f, 0x0c },
> +{ 1, 0x30, 0x3b },
> +{ 1, 0x31, 0x41 },
> +{ 1, 0x32, 0x0c },
> +{ 1, 0x33, 0x02 },
> +{ 1, 0x34, 0xb1 },
> +{ 1, 0x35, 0xed },
> +{ 1, 0x36, 0x60 },
> +{ 1, 0x37, 0xcc },
> +{ 1, 0x38, 0x6c },
> +{ 1, 0x39, 0x7d },
> +{ 1, 0x3a, 0xb1 },
> +{ 1, 0x3b, 0xed },
> +{ 1, 0x3c, 0x69 },
> +{ 1, 0x3d, 0xb3 },
> +{ 1, 0x3e, 0xed },
> +{ 1, 0x3f, 0x40 },
> +{ 1, 0x40, 0xdb },
> +{ 1, 0x41, 0xda },
> +{ 1, 0x42, 0x79 },
> +{ 1, 0x43, 0x87 },
> +{ 1, 0x44, 0xbc },
> +{ 1, 0x45, 0x3f },
> +{ 1, 0x46, 0xb7 },
> +{ 1, 0x47, 0x5e },
> +{ 1, 0x48, 0x1c },
> +{ 1, 0x49, 0xb7 },
> +{ 1, 0x4a, 0x56 },
> +{ 1, 0x4b, 0xb7 },
> +{ 1, 0x4c, 0x56 },
> +{ 1, 0x4d, 0xb7 },
> +{ 1, 0x4e, 0x56 },
> +{ 1, 0x4f, 0x63 },
> +{ 1, 0x50, 0xd5 },
> +{ 1, 0x51, 0x74 },
> +{ 1, 0x52, 0x95 },
> +{ 1, 0x53, 0x5f },
> +{ 1, 0x54, 0xc0 },
> +{ 1, 0x55, 0x73 },
> +{ 1, 0x56, 0x28 },
> +{ 1, 0x57, 0xc4 },
> +{ 1, 0x58, 0x69 },
> +{ 1, 0x59, 0x55 },
> +{ 1, 0x5a, 0x55 },
> +{ 1, 0x5b, 0x40 },
> +{ 1, 0x5c, 0x60 },
> +{ 1, 0x5d, 0xfd },
> +{ 1, 0x5e, 0x00 },
> +{ 1, 0x5f, 0x00 },
> +{ 1, 0x60, 0x30 },
> +{ 1, 0x61, 0x29 },
> +{ 1, 0x62, 0x13 },
> +{ 1, 0x63, 0xf0 },
> +{ 1, 0x64, 0x00 },
> +{ 1, 0x65, 0x96 },
> +{ 1, 0x66, 0x72 },
> +{ 1, 0x67, 0x1b },
> +{ 1, 0x68, 0x2d },
> +{ 1, 0x69, 0x97 },
> +{ 1, 0x6a, 0x4b },
> +{ 1, 0x6b, 0xde },
> +{ 1, 0x6c, 0x88 },
> +{ 1, 0x6d, 0x00 },
> +{ 1, 0x6e, 0x00 },
> +{ 1, 0x6f, 0x00 },
> +{ 1, 0x70, 0xab },
> +{ 1, 0x71, 0x2b },
> +{ 1, 0x72, 0x10 },
> +{ 1, 0x73, 0xf4 },
> +{ 1, 0x74, 0x47 },
> +{ 1, 0x75, 0x57 },
> +{ 1, 0x76, 0x40 },
> +{ 1, 0x77, 0xaa },
> +{ 1, 0x78, 0xaa },
> +{ 1, 0x79, 0x01 },
> +{ 1, 0x7a, 0x00 },
> +{ 1, 0x7b, 0x07 },
> +{ 1, 0x7c, 0x50 },
> +{ 1, 0x80, 0x00 },
> +{ 1, 0x81, 0x88 },
> +{ 1, 0x82, 0x00 },
> +{ 1, 0xf0, 0x00 },
> +{ 1, 0xf1, 0x5e },
> +{ 1, 0xf2, 0xec },
> +{ 1, 0xf3, 0x00 },
> +{ 1, 0xf4, 0x5e },
> +{ 1, 0xf5, 0xec },
> +{ 1, 0xf6, 0x05 },
> +{ 2, 0xfb, 0x03 },
> +{ 1, 0xfc, 0x00 },
> +{ 1, 0xfd, 0x00 },
> +{ 1, 0xfe, 0x00 },
> +{ 1, 0xff, 0x02 },
> +};
> +
>   #endif
>

-- 
http://palosaari.fi/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/2] mn88472: fix firmware loading
  2014-12-07 22:10 ` [PATCH 2/2] mn88472: fix firmware loading Benjamin Larsson
@ 2014-12-07 22:36   ` Antti Palosaari
  2014-12-08 11:12     ` Benjamin Larsson
  2014-12-08 16:04     ` Benjamin Larsson
  0 siblings, 2 replies; 9+ messages in thread
From: Antti Palosaari @ 2014-12-07 22:36 UTC (permalink / raw)
  To: Benjamin Larsson; +Cc: Linux Media Mailing List

On 12/08/2014 12:10 AM, Benjamin Larsson wrote:
> The firmware must be loaded one byte at a time via the 0xf6 register.

I don't think so. Currently it downloads firmware in 22 byte chunks and 
it seems to work, at least for me, both mn88472 and mn88473.

> Signed-off-by: Benjamin Larsson <benjamin@southpole.se>
> ---
>   drivers/staging/media/mn88472/mn88472.c | 21 +++++++--------------
>   1 file changed, 7 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/staging/media/mn88472/mn88472.c b/drivers/staging/media/mn88472/mn88472.c
> index ffee187..ba1bc8d 100644
> --- a/drivers/staging/media/mn88472/mn88472.c
> +++ b/drivers/staging/media/mn88472/mn88472.c
> @@ -290,7 +290,7 @@ static int mn88472_init(struct dvb_frontend *fe)
>   {
>   	struct i2c_client *client = fe->demodulator_priv;
>   	struct mn88472_dev *dev = i2c_get_clientdata(client);
> -	int ret, len, remaining;
> +	int ret, i;
>   	const struct firmware *fw = NULL;
>   	u8 *fw_file = MN88472_FIRMWARE;
>
> @@ -330,19 +330,12 @@ static int mn88472_init(struct dvb_frontend *fe)
>   	if (ret)
>   		goto err;
>
> -	for (remaining = fw->size; remaining > 0;
> -			remaining -= (dev->i2c_wr_max - 1)) {
> -		len = remaining;
> -		if (len > (dev->i2c_wr_max - 1))
> -			len = (dev->i2c_wr_max - 1);
> -
> -		ret = regmap_bulk_write(dev->regmap[0], 0xf6,
> -				&fw->data[fw->size - remaining], len);
> -		if (ret) {
> -			dev_err(&client->dev,
> -					"firmware download failed=%d\n", ret);
> -			goto err;
> -		}
> +	for (i = 0 ; i < fw->size ; i++)
> +		ret |= regmap_write(dev->regmap[0], 0xf6, fw->data[i]);
> +	if (ret) {
> +		dev_err(&client->dev,
> +				"firmware download failed=%d\n", ret);
> +		goto err;
>   	}

Not nice.

1) You mask status and you could not know if error code is valid after 
mask few thousand error codes.

2) Even worse, it is loop that runs thousand of times. Guess how much 
I/O errors there could happen. There is many times situation when first 
error occur then all the rest commands are failing too. And many cases 
failing I2C command could be failed USB message, which could take few 
seconds. Very typical USB timeout is 2 secs, this means 2k firmware, 
2*2000=4000 sec => it blocks that routine over *one* hour.

>
>   	ret = regmap_write(dev->regmap[0], 0xf5, 0x00);
>

regards
Antti

-- 
http://palosaari.fi/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/2] mn88472: fix firmware loading
  2014-12-07 22:36   ` Antti Palosaari
@ 2014-12-08 11:12     ` Benjamin Larsson
  2014-12-08 17:35       ` Antti Palosaari
  2014-12-08 16:04     ` Benjamin Larsson
  1 sibling, 1 reply; 9+ messages in thread
From: Benjamin Larsson @ 2014-12-08 11:12 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: Linux Media Mailing List

On 12/07/2014 11:36 PM, Antti Palosaari wrote:
> On 12/08/2014 12:10 AM, Benjamin Larsson wrote:
>> The firmware must be loaded one byte at a time via the 0xf6 register.
>
> I don't think so. Currently it downloads firmware in 22 byte chunks 
> and it seems to work, at least for me, both mn88472 and mn88473.

With both these changes I get much better sensitivity. So something is 
better then before. I will track down the needed changes and respin the 
patches.

MvH
Benjamin Larsson

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/2] mn88472: fix firmware loading
  2014-12-07 22:36   ` Antti Palosaari
  2014-12-08 11:12     ` Benjamin Larsson
@ 2014-12-08 16:04     ` Benjamin Larsson
  2014-12-08 17:46       ` Antti Palosaari
  1 sibling, 1 reply; 9+ messages in thread
From: Benjamin Larsson @ 2014-12-08 16:04 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: Linux Media Mailing List

On 12/07/2014 11:36 PM, Antti Palosaari wrote:
> On 12/08/2014 12:10 AM, Benjamin Larsson wrote:
>> The firmware must be loaded one byte at a time via the 0xf6 register.
>
> I don't think so. Currently it downloads firmware in 22 byte chunks 
> and it seems to work, at least for me, both mn88472 and mn88473.

Ok, I have now tried the driver with my defaults patch in and with your 
method of loading the firmware and my patch. I have my antenna placed in 
a bad location with bad reception. With my patch I am getting data from 
the device, without my patch I am not. So whatever my code does it makes 
the device more sensitive.

And then there is this comment in the regmap code:

regmap_bulk_write(): Write multiple registers to the device

In this case we want to write multiple bytes to the same register. So I 
think that my patch is correct in principle.

MvH
Benjamin Larsson

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/2] mn88472: fix firmware loading
  2014-12-08 11:12     ` Benjamin Larsson
@ 2014-12-08 17:35       ` Antti Palosaari
  0 siblings, 0 replies; 9+ messages in thread
From: Antti Palosaari @ 2014-12-08 17:35 UTC (permalink / raw)
  To: Benjamin Larsson; +Cc: Linux Media Mailing List

Moikka!

On 12/08/2014 01:12 PM, Benjamin Larsson wrote:
> On 12/07/2014 11:36 PM, Antti Palosaari wrote:
>> On 12/08/2014 12:10 AM, Benjamin Larsson wrote:
>>> The firmware must be loaded one byte at a time via the 0xf6 register.
>>
>> I don't think so. Currently it downloads firmware in 22 byte chunks
>> and it seems to work, at least for me, both mn88472 and mn88473.
>
> With both these changes I get much better sensitivity. So something is
> better then before. I will track down the needed changes and respin the
> patches.

I suspect it is that initialization of all registers which has something 
to do with sensitivity. I haven't tested if firmware uploading is 
critical, what happens when some byte is skipped or so...

Did you saw there is config parameter i2c_wr_max? Setting it to '1' does 
same what that your patch did, but leaves amount of max I2C bytes 
configurable...

Anyhow, good finding, which needs to be track down.

regards
Antti

-- 
http://palosaari.fi/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/2] mn88472: fix firmware loading
  2014-12-08 16:04     ` Benjamin Larsson
@ 2014-12-08 17:46       ` Antti Palosaari
  2014-12-08 18:54         ` Benjamin Larsson
  0 siblings, 1 reply; 9+ messages in thread
From: Antti Palosaari @ 2014-12-08 17:46 UTC (permalink / raw)
  To: Benjamin Larsson; +Cc: Linux Media Mailing List

Hello!

On 12/08/2014 06:04 PM, Benjamin Larsson wrote:
> On 12/07/2014 11:36 PM, Antti Palosaari wrote:
>> On 12/08/2014 12:10 AM, Benjamin Larsson wrote:
>>> The firmware must be loaded one byte at a time via the 0xf6 register.
>>
>> I don't think so. Currently it downloads firmware in 22 byte chunks
>> and it seems to work, at least for me, both mn88472 and mn88473.
>
> Ok, I have now tried the driver with my defaults patch in and with your
> method of loading the firmware and my patch. I have my antenna placed in
> a bad location with bad reception. With my patch I am getting data from
> the device, without my patch I am not. So whatever my code does it makes
> the device more sensitive.
>
> And then there is this comment in the regmap code:
>
> regmap_bulk_write(): Write multiple registers to the device
>
> In this case we want to write multiple bytes to the same register. So I
> think that my patch is correct in principle.

You haven't make any test whether it is possible to write that firmware 
in a large chunks *or* writing one byte (smallest possible ~chuck) at 
the time? I think it does not matter. I suspect you could even download 
whole firmware as one go - but rtl2832p I2C adapter does support only 22 
bytes on one xfer.

Even those are written to one register, chip knows how many bytes one 
message has and could increase its internal address counter. That is 
usually called register address auto-increment.

A) writing:
f6 00
f6 01
f6 02
f6 03
f6 04
f6 05
f6 06
f6 07
f6 08
f6 09

B) writing:
f6 00 01 02 03 04
f6 05 06 07 08 09

will likely end up same. B is better as only 2 xfers are done - much 
less IO.

regards
Antti

-- 
http://palosaari.fi/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/2] mn88472: fix firmware loading
  2014-12-08 17:46       ` Antti Palosaari
@ 2014-12-08 18:54         ` Benjamin Larsson
  0 siblings, 0 replies; 9+ messages in thread
From: Benjamin Larsson @ 2014-12-08 18:54 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: Linux Media Mailing List

On 12/08/2014 06:46 PM, Antti Palosaari wrote:
> Hello!
> [...]
>> regmap_bulk_write(): Write multiple registers to the device
>>
>> In this case we want to write multiple bytes to the same register. So I
>> think that my patch is correct in principle.
>
> You haven't make any test whether it is possible to write that 
> firmware in a large chunks *or* writing one byte (smallest possible 
> ~chuck) at the time? I think it does not matter. I suspect you could 
> even download whole firmware as one go - but rtl2832p I2C adapter does 
> support only 22 bytes on one xfer.
>
> Even those are written to one register, chip knows how many bytes one 
> message has and could increase its internal address counter. That is 
> usually called register address auto-increment.
>
> A) writing:
> f6 00
> f6 01
> f6 02
> f6 03
> f6 04
> f6 05
> f6 06
> f6 07
> f6 08
> f6 09
>
> B) writing:
> f6 00 01 02 03 04
> f6 05 06 07 08 09
>
> will likely end up same. B is better as only 2 xfers are done - much 
> less IO.
>
> regards
> Antti
>
Hello Antti.

I have now tried the following patch on top of my load defaults patch.

index a7d35bb..fd9796d
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -467,7 +467,7 @@ static int mn88472_probe(struct i2c_client *client,
                 goto err;
         }

-       dev->i2c_wr_max = config->i2c_wr_max;
+       dev->i2c_wr_max = 2;
         dev->xtal = config->xtal;
         dev->ts_mode = config->ts_mode;
         dev->ts_clock = config->ts_clock;

With this patch I get data, without it I don't. Based on that info I 
started testing different i2c wr max values.

When I got to 18 it stopped working. So it seams like both you and me 
where right. We can write several
values at once but only a maximum of 16.

I have a patch that adds parity check of the firmware and all the times 
the check succeeded but the demodulator
didn't deliver data. So I guess that the parity checker is before the 16 
byte buffer and if you write more the data is
just ignored.

I will send an updated patch based on this.

MvH
Benjamin Larsson

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-12-08 18:54 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-07 22:10 [PATCH 1/2] mn88472: load demodulator register defaults Benjamin Larsson
2014-12-07 22:10 ` [PATCH 2/2] mn88472: fix firmware loading Benjamin Larsson
2014-12-07 22:36   ` Antti Palosaari
2014-12-08 11:12     ` Benjamin Larsson
2014-12-08 17:35       ` Antti Palosaari
2014-12-08 16:04     ` Benjamin Larsson
2014-12-08 17:46       ` Antti Palosaari
2014-12-08 18:54         ` Benjamin Larsson
2014-12-07 22:25 ` [PATCH 1/2] mn88472: load demodulator register defaults Antti Palosaari

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.