[PATCH] media: radio: Tuning bugfix for si470x over i2c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Fixed si470x_set_channel() trying to tune before chip is turned
on, which causes warnings in dmesg and when probing, makes driver
wait for 3s for tuning timeout. This issue did not affect USB
devices because they have a different probing sequence.

Signed-off-by: Douglas Fischer <fischerdouglasc@xxxxxxxxx>
---

diff -uprN linux.orig/drivers/media/radio/si470x/radio-si470x-common.c
linux/drivers/media/radio/si470x/radio-si470x-common.c ---
linux.orig/drivers/media/radio/si470x/radio-si470x-common.c
2018-01-15 21:58:10.675620432 -0500 +++
linux/drivers/media/radio/si470x/radio-si470x-common.c
2018-01-16 17:04:59.706409128 -0500 @@ -207,29 +207,37 @@ static int
si470x_set_chan(struct si470x unsigned long time_left; bool timed_out =
false; 
-	/* start tuning */
-	radio->registers[CHANNEL] &= ~CHANNEL_CHAN;
-	radio->registers[CHANNEL] |= CHANNEL_TUNE | chan;
-	retval = si470x_set_register(radio, CHANNEL);
-	if (retval < 0)
-		goto done;
+	retval = si470x_get_register(radio, POWERCFG);
+	if (retval)
+		return retval;
 
-	/* wait till tune operation has completed */
-	reinit_completion(&radio->completion);
-	time_left = wait_for_completion_timeout(&radio->completion,
-
msecs_to_jiffies(tune_timeout));
-	if (time_left == 0)
-		timed_out = true;
+	if ( (radio->registers[POWERCFG] & POWERCFG_ENABLE) && 
+		(radio->registers[POWERCFG] & POWERCFG_DMUTE) ) { 
 
-	if ((radio->registers[STATUSRSSI] & STATUSRSSI_STC) == 0)
-		dev_warn(&radio->videodev.dev, "tune does not
complete\n");
-	if (timed_out)
-		dev_warn(&radio->videodev.dev,
-			"tune timed out after %u ms\n", tune_timeout);
+		/* start tuning */
+		radio->registers[CHANNEL] &= ~CHANNEL_CHAN;
+		radio->registers[CHANNEL] |= CHANNEL_TUNE | chan;
+		retval = si470x_set_register(radio, CHANNEL);
+		if (retval < 0)
+			goto done;
 
-	/* stop tuning */
-	radio->registers[CHANNEL] &= ~CHANNEL_TUNE;
-	retval = si470x_set_register(radio, CHANNEL);
+		/* wait till tune operation has completed */
+		reinit_completion(&radio->completion);
+		time_left =
wait_for_completion_timeout(&radio->completion,
+
msecs_to_jiffies(tune_timeout));
+		if (time_left == 0)
+			timed_out = true;
+	
+		if ((radio->registers[STATUSRSSI] & STATUSRSSI_STC) ==
0)
+			dev_warn(&radio->videodev.dev, "tune does not
complete\n");
+		if (timed_out)
+			dev_warn(&radio->videodev.dev,
+				"tune timed out after %u ms\n",
tune_timeout);
+	
+		/* stop tuning */
+		radio->registers[CHANNEL] &= ~CHANNEL_TUNE;
+		retval = si470x_set_register(radio, CHANNEL);
+	}
 
 done:
 	return retval;



[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux