Skip to content

Commit

Permalink
modified si470x driver without interruptions
Browse files Browse the repository at this point in the history
  • Loading branch information
astroza committed May 18, 2016
1 parent cb3e534 commit 4257587
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
6 changes: 4 additions & 2 deletions radio-si470x-common.c
Expand Up @@ -143,9 +143,9 @@ module_param(de, ushort, 0444);
MODULE_PARM_DESC(de, "De-emphasis: 0=75us *1=50us*");

/* Tune timeout */
static unsigned int tune_timeout = 3000;
static unsigned int tune_timeout = 5000;
module_param(tune_timeout, uint, 0644);
MODULE_PARM_DESC(tune_timeout, "Tune timeout: *3000*");
MODULE_PARM_DESC(tune_timeout, "Tune timeout: *5000*");

/* Seek timeout */
static unsigned int seek_timeout = 5000;
Expand Down Expand Up @@ -187,6 +187,7 @@ static int si470x_set_chan(struct si470x_device *radio, unsigned short chan)
/* wait till tune operation has completed */
timeout = jiffies + msecs_to_jiffies(tune_timeout);
do {
dev_warn(&radio->videodev->dev, "Waiting tune response\n");
retval = si470x_get_register(radio, STATUSRSSI);
if (retval < 0)
goto stop;
Expand Down Expand Up @@ -373,6 +374,7 @@ int si470x_start(struct si470x_device *radio)
{
int retval;

dev_warn(&radio->videodev->dev, "si470x_start\n");
/* powercfg */
radio->registers[POWERCFG] =
POWERCFG_DMUTE | POWERCFG_ENABLE | POWERCFG_RDSM;
Expand Down
36 changes: 22 additions & 14 deletions radio-si470x-i2c.c
Expand Up @@ -385,14 +385,31 @@ static int __devinit si470x_i2c_probe(struct i2c_client *client,
sizeof(si470x_viddev_template));
video_set_drvdata(radio->videodev, radio);

/* power up : need 110ms */
radio->registers[POWERCFG] = POWERCFG_ENABLE;
if (si470x_get_all_registers(radio) < 0) {
retval = -EIO;
goto err_video;
}

radio->registers[TEST1] |= TEST1_XOSCEN;
if (si470x_set_register(radio, TEST1) < 0) {
retval = -EIO;
goto err_video;
}
msleep(500);
/* Needed for cold starting */
radio->registers[POWERCFG] = POWERCFG_DISABLE | POWERCFG_ENABLE;
if (si470x_set_register(radio, POWERCFG) < 0) {
retval = -EIO;
goto err_video;
}
msleep(110);

/* Enable the chip */
radio->registers[POWERCFG] = POWERCFG_ENABLE;
if (si470x_set_register(radio, POWERCFG) < 0) {
retval = -EIO;
goto err_video;
}
msleep(110);
/* get device and chip versions */
if (si470x_get_all_registers(radio) < 0) {
retval = -EIO;
Expand Down Expand Up @@ -436,15 +453,8 @@ static int __devinit si470x_i2c_probe(struct i2c_client *client,
init_waitqueue_head(&radio->read_queue);

/* mark Seek/Tune Complete Interrupt enabled */
radio->stci_enabled = true;
init_completion(&radio->completion);

retval = request_threaded_irq(client->irq, NULL, si470x_i2c_interrupt,
IRQF_TRIGGER_FALLING, DRIVER_NAME, radio);
if (retval) {
dev_err(&client->dev, "Failed to register interrupt\n");
goto err_rds;
}
// radio->stci_enabled = true;
// init_completion(&radio->completion);

/* register video device */
retval = video_register_device(radio->videodev, VFL_TYPE_RADIO,
Expand All @@ -457,7 +467,6 @@ static int __devinit si470x_i2c_probe(struct i2c_client *client,

return 0;
err_all:
free_irq(client->irq, radio);
err_rds:
kfree(radio->buffer);
err_video:
Expand All @@ -476,7 +485,6 @@ static __devexit int si470x_i2c_remove(struct i2c_client *client)
{
struct si470x_device *radio = i2c_get_clientdata(client);

free_irq(client->irq, radio);
video_unregister_device(radio->videodev);
kfree(radio);

Expand Down
1 change: 1 addition & 0 deletions radio-si470x.h
Expand Up @@ -95,6 +95,7 @@
#define SYSCONFIG3_SKCNT 0x000f /* bits 03..00: Seek FM Impulse Detection Threshold */

#define TEST1 7 /* Test 1 */
#define TEST1_XOSCEN 0x8000
#define TEST1_AHIZEN 0x4000 /* bits 14..14: Audio High-Z Enable */

#define TEST2 8 /* Test 2 */
Expand Down

0 comments on commit 4257587

Please sign in to comment.