aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xfree86/i2c/fi1236.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-03-23 10:05:55 +0100
committermarha <marha@users.sourceforge.net>2012-03-23 10:05:55 +0100
commit0f834b91a4768673833ab4917e87d86c237bb1a6 (patch)
tree363489504ed4b2d360259b8de4c9e392918e5d02 /xorg-server/hw/xfree86/i2c/fi1236.c
parentfc72edebf875378459368c5383d9023730cbca54 (diff)
downloadvcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.tar.gz
vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.tar.bz2
vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.zip
libX11 xserver fontconfig mesa pixman xkbcomp xkeyboard-config git update
23 Mar 2012
Diffstat (limited to 'xorg-server/hw/xfree86/i2c/fi1236.c')
-rw-r--r--xorg-server/hw/xfree86/i2c/fi1236.c277
1 files changed, 144 insertions, 133 deletions
diff --git a/xorg-server/hw/xfree86/i2c/fi1236.c b/xorg-server/hw/xfree86/i2c/fi1236.c
index 0bc50e566..282fe7e34 100644
--- a/xorg-server/hw/xfree86/i2c/fi1236.c
+++ b/xorg-server/hw/xfree86/i2c/fi1236.c
@@ -15,38 +15,36 @@
#define NUM_TUNERS 8
-const FI1236_parameters tuner_parms[NUM_TUNERS] =
-{
+const FI1236_parameters tuner_parms[NUM_TUNERS] = {
/* 0 - FI1236 */
- { 733, 884, 12820, 2516, 7220, 0xA2, 0x94, 0x34, 0x8e },
+ {733, 884, 12820, 2516, 7220, 0xA2, 0x94, 0x34, 0x8e},
/* !!!based on documentation - it should be:
- {733, 16*55.25, 16*801.25, 16*160, 16*454, 0xA0, 0x90, 0x30, 0x8e},*/
+ {733, 16*55.25, 16*801.25, 16*160, 16*454, 0xA0, 0x90, 0x30, 0x8e}, */
/* 1 - FI1216 */
- { 623, 16*48.75, 16*855.25, 16*170, 16*450, 0xA0, 0x90, 0x30, 0x8e },
+ {623, 16 * 48.75, 16 * 855.25, 16 * 170, 16 * 450, 0xA0, 0x90, 0x30, 0x8e},
/* 2 - TEMIC FN5AL */
- { 623, 16*45.75, 16*855.25, 16*169, 16*454, 0xA0, 0x90, 0x30, 0x8e },
+ {623, 16 * 45.75, 16 * 855.25, 16 * 169, 16 * 454, 0xA0, 0x90, 0x30, 0x8e},
/* 3 - MT2032.. */
- { 733, 768, 13760, 0, 0, 0, 0, 0, 0 },
+ {733, 768, 13760, 0, 0, 0, 0, 0, 0},
/* 4 - FI1246 */
- { 623, 16*45.75, 16*855.25, 16*170, 16*450, 0xA0, 0x90, 0x30, 0x8e },
+ {623, 16 * 45.75, 16 * 855.25, 16 * 170, 16 * 450, 0xA0, 0x90, 0x30, 0x8e},
/* 5 - FI1256 */
- { 623, 16*49.75, 16*863.25, 16*170, 16*450, 0xA0, 0x90, 0x30, 0x8e },
+ {623, 16 * 49.75, 16 * 863.25, 16 * 170, 16 * 450, 0xA0, 0x90, 0x30, 0x8e},
/* 6 - FI1236W */
- /*{ 733, 884, 12820, 2516, 7220, 0x1, 0x2, 0x4, 0x8e },*/
- { 732, 16*55.25, 16*801.25, 16*160, 16*442, 0x1, 0x2, 0x4, 0x8e },
+ /*{ 733, 884, 12820, 2516, 7220, 0x1, 0x2, 0x4, 0x8e }, */
+ {732, 16 * 55.25, 16 * 801.25, 16 * 160, 16 * 442, 0x1, 0x2, 0x4, 0x8e},
/* 7 - FM1216ME */
- { 623, 16*48.25, 16*863.25, 16*158.00, 16*442.00, 0x1, 0x2, 0x4, 0x8e }
+ {623, 16 * 48.25, 16 * 863.25, 16 * 158.00, 16 * 442.00, 0x1, 0x2, 0x4, 0x8e}
};
-
FI1236Ptr
-Detect_FI1236 (I2CBusPtr b, I2CSlaveAddr addr)
+Detect_FI1236(I2CBusPtr b, I2CSlaveAddr addr)
{
FI1236Ptr f;
I2CByte a;
- f = calloc(1,sizeof(FI1236Rec));
+ f = calloc(1, sizeof(FI1236Rec));
if (f == NULL)
return NULL;
f->d.DevName = strdup("FI12xx Tuner");
@@ -57,10 +55,10 @@ Detect_FI1236 (I2CBusPtr b, I2CSlaveAddr addr)
f->d.BitTimeout = b->BitTimeout;
f->d.AcknTimeout = b->AcknTimeout;
f->d.ByteTimeout = b->ByteTimeout;
- f->type=TUNER_TYPE_FI1236;
- f->afc_timer_installed=FALSE;
- f->last_afc_hint=TUNER_OFF;
- f->video_if=45.7812;
+ f->type = TUNER_TYPE_FI1236;
+ f->afc_timer_installed = FALSE;
+ f->last_afc_hint = TUNER_OFF;
+ f->video_if = 45.7812;
if (!I2C_WriteRead(&(f->d), NULL, 0, &a, 1)) {
free(f);
@@ -75,7 +73,7 @@ Detect_FI1236 (I2CBusPtr b, I2CSlaveAddr addr)
}
static void
-MT2032_dump_parameters (FI1236Ptr f, MT2032_parameters *m)
+MT2032_dump_parameters(FI1236Ptr f, MT2032_parameters * m)
{
xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
"MT2032: input f_rf=%g f_if1=%g f_if2=%g f_ref=%g f_ifbw=%g f_step=%g\n",
@@ -86,15 +84,14 @@ MT2032_dump_parameters (FI1236Ptr f, MT2032_parameters *m)
m->f_lo1, m->f_lo2, m->LO1I, m->LO2I, m->SEL, m->STEP, m->NUM);
}
-
static void
-MT2032_getid (FI1236Ptr f)
+MT2032_getid(FI1236Ptr f)
{
CARD8 out[4];
CARD8 in;
in = 0x11;
- I2C_WriteRead(&(f->d), (I2CByte *)&in, 1, out, 4);
+ I2C_WriteRead(&(f->d), (I2CByte *) & in, 1, out, 4);
xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
"MT2032: Company code 0x%02x%02x, part code 0x%02x, revision code 0x%02x\n",
out[0], out[1], out[2], out[3]);
@@ -104,37 +101,37 @@ MT2032_getid (FI1236Ptr f)
/* might be buggy */
#if 0
static void
-MT2032_shutdown (FI1236Ptr f)
+MT2032_shutdown(FI1236Ptr f)
{
CARD8 data[10];
- data[0] = 0x00; /* start with register 0x00 */
+ data[0] = 0x00; /* start with register 0x00 */
data[1] = 0x1A;
data[2] = 0x44;
data[3] = 0x20;
- I2C_WriteRead(&(f->d), (I2CByte *)data, 4, NULL, 0);
+ I2C_WriteRead(&(f->d), (I2CByte *) data, 4, NULL, 0);
- data[0] = 0x05; /* now start with register 0x05 */
+ data[0] = 0x05; /* now start with register 0x05 */
data[1] = 0xD7;
data[2] = 0x14;
data[3] = 0x05;
- I2C_WriteRead(&(f->d), (I2CByte *)data, 4, NULL, 0);
+ I2C_WriteRead(&(f->d), (I2CByte *) data, 4, NULL, 0);
- data[0] = 0x0B; /* now start with register 0x05 */
+ data[0] = 0x0B; /* now start with register 0x05 */
data[1] = 0x8F;
data[2] = 0x07;
data[3] = 0x43;
- I2C_WriteRead(&(f->d), (I2CByte *)data, 4, NULL, 0);
+ I2C_WriteRead(&(f->d), (I2CByte *) data, 4, NULL, 0);
usleep(15000);
}
#endif
-static void MT2032_dump_status (FI1236Ptr f);
+static void MT2032_dump_status(FI1236Ptr f);
static void
-MT2032_init (FI1236Ptr f)
+MT2032_init(FI1236Ptr f)
{
CARD8 data[10];
CARD8 value;
@@ -142,31 +139,31 @@ MT2032_init (FI1236Ptr f)
MT2032_getid(f);
- data[0] = 0x02; /* start with register 0x02 */
+ data[0] = 0x02; /* start with register 0x02 */
data[1] = 0xFF;
data[2] = 0x0F;
data[3] = 0x1F;
- I2C_WriteRead(&(f->d), (I2CByte *)data, 4, NULL, 0);
+ I2C_WriteRead(&(f->d), (I2CByte *) data, 4, NULL, 0);
- data[0] = 0x06; /* now start with register 0x06 */
+ data[0] = 0x06; /* now start with register 0x06 */
data[1] = 0xE4;
data[2] = 0x8F;
data[3] = 0xC3;
data[4] = 0x4E;
data[5] = 0xEC;
- I2C_WriteRead(&(f->d), (I2CByte *)data, 6, NULL, 0);
+ I2C_WriteRead(&(f->d), (I2CByte *) data, 6, NULL, 0);
- data[0] = 0x0d; /* now start with register 0x0d */
+ data[0] = 0x0d; /* now start with register 0x0d */
data[1] = 0x32;
- I2C_WriteRead(&(f->d), (I2CByte *)data, 2, NULL, 0);
+ I2C_WriteRead(&(f->d), (I2CByte *) data, 2, NULL, 0);
while (1) {
- usleep(15000); /* wait 15 milliseconds */
+ usleep(15000); /* wait 15 milliseconds */
- data[0] = 0x0e; /* register number 7, status */
+ data[0] = 0x0e; /* register number 7, status */
value = 0xFF;
- if (!I2C_WriteRead(&(f->d), (I2CByte *)data, 1, &value, 1))
+ if (!I2C_WriteRead(&(f->d), (I2CByte *) data, 1, &value, 1))
xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
"MT2032: failed to read XOK\n");
xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
@@ -175,32 +172,33 @@ MT2032_init (FI1236Ptr f)
break;
data[0] = 0x07;
- if (!I2C_WriteRead(&(f->d), (I2CByte *)data, 1, &value, 1))
+ if (!I2C_WriteRead(&(f->d), (I2CByte *) data, 1, &value, 1))
xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
"MT2032: failed to read XOGC\n");
- xogc=value & 0x7;
+ xogc = value & 0x7;
if (xogc == 4)
- break; /* XOGC has reached 4.. stop */
+ break; /* XOGC has reached 4.. stop */
xogc--;
xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
"MT2032: try XOGC=%d\n", xogc);
usleep(15000);
- data[0] = 0x07; /* register number 7, control byte 2 */
+ data[0] = 0x07; /* register number 7, control byte 2 */
data[1] = 0x08 | xogc;
- I2C_WriteRead(&(f->d), (I2CByte *)data, 2, NULL, 0);
+ I2C_WriteRead(&(f->d), (I2CByte *) data, 2, NULL, 0);
}
f->xogc = xogc;
/* wait before continuing */
- usleep(15000); /* wait 50 milliseconds */
+ usleep(15000); /* wait 50 milliseconds */
MT2032_dump_status(f);
}
static int
-MT2032_no_spur_in_band (MT2032_parameters *m)
+MT2032_no_spur_in_band(MT2032_parameters * m)
{
int n_max, n1, n2;
double f_test;
+
n_max = 5;
n1 = 1;
while (1) {
@@ -233,10 +231,12 @@ MT2032_no_spur_in_band (MT2032_parameters *m)
}
static void
-MT2032_calculate_register_settings (MT2032_parameters *m, double f_rf,
- double f_if1, double f_if2, double f_ref, double f_ifbw, double f_step)
+MT2032_calculate_register_settings(MT2032_parameters * m, double f_rf,
+ double f_if1, double f_if2, double f_ref,
+ double f_ifbw, double f_step)
{
int n;
+
m->f_rf = f_rf;
m->f_if1 = f_if1;
m->f_if2 = f_if2;
@@ -244,7 +244,7 @@ MT2032_calculate_register_settings (MT2032_parameters *m, double f_rf,
m->f_ifbw = f_ifbw;
m->f_step = f_step;
- m->f_lo1 = f_rf+f_if1;
+ m->f_lo1 = f_rf + f_if1;
m->LO1I = lrint(m->f_lo1 / f_ref);
m->f_lo1 = f_ref * m->LO1I;
@@ -277,33 +277,33 @@ MT2032_calculate_register_settings (MT2032_parameters *m, double f_rf,
m->SEL = 2;
else if (m->f_lo1 < 1890.0)
m->SEL = 1;
- else /* m->f_lo1 < 1958.0 */
+ else /* m->f_lo1 < 1958.0 */
m->SEL = 0;
/* calculate the rest of the registers */
m->LO2I = floor(m->f_lo2 / f_ref);
m->STEP = floor(3780.0 * f_step / f_ref);
- m->NUM = floor(3780.0 * (m->f_lo2 / f_ref - m->LO2I));
- m->NUM = m->STEP * lrint((1.0 * m->NUM) / (1.0 * m->STEP));
+ m->NUM = floor(3780.0 * (m->f_lo2 / f_ref - m->LO2I));
+ m->NUM = m->STEP * lrint((1.0 * m->NUM) / (1.0 * m->STEP));
}
static int
-MT2032_wait_for_lock (FI1236Ptr f)
+MT2032_wait_for_lock(FI1236Ptr f)
{
int n;
CARD8 data[10];
CARD8 value;
- n=12;
- while(1) {
- data[0] = 0x0e; /* register number 7, status */
- I2C_WriteRead(&(f->d), (I2CByte *)data, 1, &value, 1);
- /* xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
- "MT2032: LO1LK=%d LO2LK=%d\n",
- (value & 0x04)>>2, (value & 0x02)>>1); */
- if ((value & 6)==6)
+ n = 12;
+ while (1) {
+ data[0] = 0x0e; /* register number 7, status */
+ I2C_WriteRead(&(f->d), (I2CByte *) data, 1, &value, 1);
+ /* xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
+ "MT2032: LO1LK=%d LO2LK=%d\n",
+ (value & 0x04)>>2, (value & 0x02)>>1); */
+ if ((value & 6) == 6)
break;
- usleep (1500);
+ usleep(1500);
n--;
if (n < 0)
break;
@@ -317,50 +317,50 @@ MT2032_wait_for_lock (FI1236Ptr f)
}
static void
-MT2032_implement_settings (FI1236Ptr f, MT2032_parameters *m)
+MT2032_implement_settings(FI1236Ptr f, MT2032_parameters * m)
{
CARD8 data[10];
CARD8 value;
- data[0] = 0x00; /* start with register 0x00 */
+ data[0] = 0x00; /* start with register 0x00 */
data[1] = (m->LO1I >> 3) - 1;
data[2] = (m->SEL << 4) | (m->LO1I & 0x7);
data[3] = 0x86;
- I2C_WriteRead(&(f->d), (I2CByte *)data, 4, NULL, 0);
+ I2C_WriteRead(&(f->d), (I2CByte *) data, 4, NULL, 0);
- data[0] = 0x05; /* start with register 0x05 */
+ data[0] = 0x05; /* start with register 0x05 */
data[1] = ((m->LO2I & 0x7) << 5) | ((m->LO2I >> 3) - 1);
if (m->f_rf < 400.0)
data[2] = 0xe4;
else
data[2] = 0xf4;
- I2C_WriteRead(&(f->d), (I2CByte *)data, 3, NULL, 0);
+ I2C_WriteRead(&(f->d), (I2CByte *) data, 3, NULL, 0);
- data[0] = 0x07; /* register number 7, control byte 2 */
- I2C_WriteRead(&(f->d), (I2CByte *)data, 1, &value, 1);
+ data[0] = 0x07; /* register number 7, control byte 2 */
+ I2C_WriteRead(&(f->d), (I2CByte *) data, 1, &value, 1);
xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
"MT2032: using XOGC=%d\n", (value & 0x07));
data[1] = 8 | (value & 0x7);
- I2C_WriteRead(&(f->d), (I2CByte *)data, 2, NULL, 0);
+ I2C_WriteRead(&(f->d), (I2CByte *) data, 2, NULL, 0);
- data[0] = 0x0b; /* start with register 0x0b */
+ data[0] = 0x0b; /* start with register 0x0b */
data[1] = m->NUM & 0xff;
- data[2] = (1<<7) | ((m->NUM >> 8) & 0x0f);
- I2C_WriteRead(&(f->d), (I2CByte *)data, 3, NULL, 0);
+ data[2] = (1 << 7) | ((m->NUM >> 8) & 0x0f);
+ I2C_WriteRead(&(f->d), (I2CByte *) data, 3, NULL, 0);
MT2032_wait_for_lock(f);
}
static void
-MT2032_optimize_VCO (FI1236Ptr f, MT2032_parameters *m)
+MT2032_optimize_VCO(FI1236Ptr f, MT2032_parameters * m)
{
CARD8 data[10];
CARD8 value;
CARD8 TAD1;
- data[0] = 0x0f; /* register number 7, status */
- I2C_WriteRead(&(f->d), (I2CByte *)data, 1, &value, 1);
- TAD1=value & 0x07;
+ data[0] = 0x0f; /* register number 7, status */
+ I2C_WriteRead(&(f->d), (I2CByte *) data, 1, &value, 1);
+ TAD1 = value & 0x07;
xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
"MT2032: TAD1=%d SEL=%d\n", TAD1, m->SEL);
if (TAD1 < 2)
@@ -369,25 +369,27 @@ MT2032_optimize_VCO (FI1236Ptr f, MT2032_parameters *m)
if (m->SEL == 0)
return;
m->SEL--;
- } else {
+ }
+ else {
if (m->SEL >= 4)
return;
m->SEL++;
}
- data[0] = 0x01; /* start with register 1 */
+ data[0] = 0x01; /* start with register 1 */
data[1] = (m->SEL << 4) | (m->LO1I & 0x7);
- I2C_WriteRead(&(f->d), (I2CByte *)data, 2, NULL, 0);
+ I2C_WriteRead(&(f->d), (I2CByte *) data, 2, NULL, 0);
}
static int
-FI1236_get_afc_hint (FI1236Ptr f)
+FI1236_get_afc_hint(FI1236Ptr f)
{
CARD8 out;
CARD8 AFC;
if ((f->type == TUNER_TYPE_FM1216ME) || (f->type == TUNER_TYPE_FI1236W)) {
- TDA9885Ptr t = (TDA9885Ptr)f->afc_source;
+ TDA9885Ptr t = (TDA9885Ptr) f->afc_source;
+
if (t == NULL)
return TUNER_OFF;
@@ -405,7 +407,8 @@ FI1236_get_afc_hint (FI1236Ptr f)
return TUNER_JUST_ABOVE;
else if (AFC == 0x0f)
return TUNER_TUNED;
- } else {
+ }
+ else {
I2C_WriteRead(&(f->d), NULL, 0, &out, 1);
AFC = out & 0x7;
xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
@@ -422,17 +425,18 @@ FI1236_get_afc_hint (FI1236Ptr f)
}
static int
-MT2032_get_afc_hint (FI1236Ptr f)
+MT2032_get_afc_hint(FI1236Ptr f)
{
CARD8 in;
CARD8 out[2];
CARD8 AFC;
+
in = 0x0e;
- I2C_WriteRead(&(f->d), (I2CByte *)&in, 1, out, 2);
+ I2C_WriteRead(&(f->d), (I2CByte *) & in, 1, out, 2);
AFC = (out[0] >> 4) & 0x7;
#if 0
xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "AFC=%d TAD1=%d TAD2=%d\n",
- AFC, out[1] & 0x7, (out[1]>>4)& 0x07);
+ AFC, out[1] & 0x7, (out[1] >> 4) & 0x07);
#endif
if (AFC == 2)
return TUNER_TUNED;
@@ -445,7 +449,7 @@ MT2032_get_afc_hint (FI1236Ptr f)
/* this function is for external use only */
int
-TUNER_get_afc_hint (FI1236Ptr f)
+TUNER_get_afc_hint(FI1236Ptr f)
{
if (f->afc_timer_installed)
return TUNER_STILL_TUNING;
@@ -453,7 +457,7 @@ TUNER_get_afc_hint (FI1236Ptr f)
}
static void
-MT2032_dump_status (FI1236Ptr f)
+MT2032_dump_status(FI1236Ptr f)
{
CARD8 in;
CARD8 out[2];
@@ -463,16 +467,16 @@ MT2032_dump_status (FI1236Ptr f)
CARD8 TAD2, TAD1;
in = 0x0e;
- I2C_WriteRead(&(f->d), (I2CByte *)&in, 1, out, 2);
+ I2C_WriteRead(&(f->d), (I2CByte *) & in, 1, out, 2);
XOK = out[0] & 1;
- LO1LK = (out[0] >> 2) & 1;
- LO2LK = (out[0] >> 1) & 1;
+ LO1LK = (out[0] >> 2) & 1;
+ LO2LK = (out[0] >> 1) & 1;
LDONrb = (out[0] >> 3) & 1;
- AFC = (out[0] >> 4) & 0x7;
+ AFC = (out[0] >> 4) & 0x7;
- TAD1 = (out[1] & 0x7);
- TAD2 = (out[1] >> 4) & 0x7;
+ TAD1 = (out[1] & 0x7);
+ TAD2 = (out[1] >> 4) & 0x7;
xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
"MT2032: status: XOK=%d LO1LK=%d LO2LK=%d LDONrb=%d AFC=%d TAD1=%d TAD2=%d\n",
@@ -480,12 +484,12 @@ MT2032_dump_status (FI1236Ptr f)
xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
"MT2032: status: OSCILLATOR:%s PLL1:%s PLL2:%s\n",
XOK ? "ok" : "off",
- LO1LK ? "locked" : "off",
- LO2LK ? "locked" : "off");
+ LO1LK ? "locked" : "off", LO2LK ? "locked" : "off");
}
-static void MT2032_tune(FI1236Ptr f, double freq, double step)
+static void
+MT2032_tune(FI1236Ptr f, double freq, double step)
{
MT2032_parameters m;
CARD8 data[10];
@@ -494,38 +498,41 @@ static void MT2032_tune(FI1236Ptr f, double freq, double step)
/* NTSC IF is 44mhz.. but 733/16=45.8125 and all TDAXXXX docs mention
45.75, 39, 58.75 and 30. */
#if 0
- MT2032_calculate_register_settings(&m, freq, 1090.0, 45.125, 5.25, 6.0, step);
- MT2032_calculate_register_settings(&m, freq, 1090.0, 45.74, 5.25, 6.0, step);
+ MT2032_calculate_register_settings(&m, freq, 1090.0, 45.125, 5.25, 6.0,
+ step);
+ MT2032_calculate_register_settings(&m, freq, 1090.0, 45.74, 5.25, 6.0,
+ step);
#endif
- MT2032_calculate_register_settings(&m, freq, 1090.0, f->video_if, 5.25, 3.0, step);
+ MT2032_calculate_register_settings(&m, freq, 1090.0, f->video_if, 5.25, 3.0,
+ step);
MT2032_dump_parameters(f, &m);
MT2032_implement_settings(f, &m);
- /* MT2032_dump_parameters(f, &m); */
+ /* MT2032_dump_parameters(f, &m); */
for (i = 0; i < 3; i++) {
MT2032_optimize_VCO(f, &m);
if (MT2032_wait_for_lock(f)) {
- data[0] = 0x02; /* LO Gain control register 0x02 */
+ data[0] = 0x02; /* LO Gain control register 0x02 */
data[1] = 0x20;
- I2C_WriteRead(&(f->d), (I2CByte *)data, 2, NULL, 0);
+ I2C_WriteRead(&(f->d), (I2CByte *) data, 2, NULL, 0);
return;
}
data[0] = 0x07;
data[1] = 0x88 | f->xogc;
- I2C_WriteRead(&(f->d), (I2CByte *)data, 2, NULL, 0);
+ I2C_WriteRead(&(f->d), (I2CByte *) data, 2, NULL, 0);
usleep(15000);
data[1] = 0x08 | f->xogc;
- I2C_WriteRead(&(f->d), (I2CByte *)data, 2, NULL, 0);
+ I2C_WriteRead(&(f->d), (I2CByte *) data, 2, NULL, 0);
}
xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
"MT2032: failed to set frequency\n");
}
void
-FI1236_set_tuner_type (FI1236Ptr f, int type)
+FI1236_set_tuner_type(FI1236Ptr f, int type)
{
f->type = type;
if (type >= NUM_TUNERS)
- type = NUM_TUNERS-1;
+ type = NUM_TUNERS - 1;
if (type < 0)
type = 0;
memcpy(&(f->parm), &(tuner_parms[type]), sizeof(FI1236_parameters));
@@ -537,11 +544,11 @@ FI1236_set_tuner_type (FI1236Ptr f, int type)
}
}
-
static CARD32
AFC_TimerCallback(OsTimerPtr timer, CARD32 time, pointer data)
{
- FI1236Ptr f = (FI1236Ptr)data;
+ FI1236Ptr f = (FI1236Ptr) data;
+
if (FI1236_AFC(f))
return 150;
else {
@@ -557,12 +564,14 @@ FI1236_tune(FI1236Ptr f, CARD32 frequency)
CARD16 divider;
CARD8 data;
- if (frequency < f->parm.min_freq) frequency = f->parm.min_freq;
- if (frequency > f->parm.max_freq) frequency = f->parm.max_freq;
+ if (frequency < f->parm.min_freq)
+ frequency = f->parm.min_freq;
+ if (frequency > f->parm.max_freq)
+ frequency = f->parm.max_freq;
- divider = (f->parm.fcar + (CARD16)frequency) & 0x7fff;
- f->tuner_data.div1 = (CARD8)((divider >> 8)&0x7f);
- f->tuner_data.div2 = (CARD8)(divider & 0xff);
+ divider = (f->parm.fcar + (CARD16) frequency) & 0x7fff;
+ f->tuner_data.div1 = (CARD8) ((divider >> 8) & 0x7f);
+ f->tuner_data.div2 = (CARD8) (divider & 0xff);
f->tuner_data.control = f->parm.control;
if (frequency < f->parm.threshold1)
@@ -576,41 +585,42 @@ FI1236_tune(FI1236Ptr f, CARD32 frequency)
"Setting tuner band to %d\n", f->tuner_data.band);
xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
- "Setting tuner frequency to %d\n", (int)frequency);
+ "Setting tuner frequency to %d\n", (int) frequency);
if ((f->type == TUNER_TYPE_FM1216ME) || (f->type == TUNER_TYPE_FI1236W)) {
f->tuner_data.aux = 0x20;
- I2C_WriteRead(&(f->d), (I2CByte *)&(f->tuner_data), 5, NULL, 0);
+ I2C_WriteRead(&(f->d), (I2CByte *) & (f->tuner_data), 5, NULL, 0);
I2C_WriteRead(&(f->d), NULL, 0, &data, 1);
xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "Tuner status %x\n", data);
}
else
- I2C_WriteRead(&(f->d), (I2CByte *)&(f->tuner_data), 4, NULL, 0);
+ I2C_WriteRead(&(f->d), (I2CByte *) & (f->tuner_data), 4, NULL, 0);
}
void
TUNER_set_frequency(FI1236Ptr f, CARD32 frequency)
{
- if (frequency < f->parm.min_freq) frequency = f->parm.min_freq;
- if (frequency > f->parm.max_freq) frequency = f->parm.max_freq;
+ if (frequency < f->parm.min_freq)
+ frequency = f->parm.min_freq;
+ if (frequency > f->parm.max_freq)
+ frequency = f->parm.max_freq;
- f->afc_delta=0;
- f->original_frequency=frequency;
+ f->afc_delta = 0;
+ f->original_frequency = frequency;
if (f->type == TUNER_TYPE_MT2032)
- MT2032_tune(f, (1.0*frequency)/16.0, 0.0625);
+ MT2032_tune(f, (1.0 * frequency) / 16.0, 0.0625);
else
FI1236_tune(f, frequency);
if (!f->afc_timer_installed) {
- f->afc_timer_installed=TRUE;
+ f->afc_timer_installed = TRUE;
/* RegisterBlockAndWakeupHandlers(FI1236_BlockHandler, AFCWakeup, f); */
TimerSet(NULL, 0, 300, AFC_TimerCallback, f);
}
}
-
int
FI1236_AFC(FI1236Ptr f)
{
@@ -637,12 +647,13 @@ FI1236_AFC(FI1236Ptr f)
"AFC: Setting tuner frequency to %g\n",
(0.5 * (2 * f->original_frequency + f->afc_delta)) / 16.0);
MT2032_tune(f,
- (1.0 * f->original_frequency+ 0.5 * f->afc_delta) / 16.0,
+ (1.0 * f->original_frequency + 0.5 * f->afc_delta) / 16.0,
0.03125);
if (f->last_afc_hint == TUNER_OFF)
return 0;
- return 1; /* call me again */
- } else {
+ return 1; /* call me again */
+ }
+ else {
f->last_afc_hint = FI1236_get_afc_hint(f);
if (f->last_afc_hint == TUNER_TUNED) {
xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "AFC: TUNER_TUNNED\n");
@@ -652,9 +663,9 @@ FI1236_AFC(FI1236Ptr f)
f->last_afc_hint = TUNER_OFF;
if (f->last_afc_hint == TUNER_OFF)
- f->afc_delta=0;
+ f->afc_delta = 0;
else
- f->afc_delta+=f->last_afc_hint;
+ f->afc_delta += f->last_afc_hint;
xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
"AFC: Setting tuner frequency to %g\n",
@@ -662,9 +673,9 @@ FI1236_AFC(FI1236Ptr f)
FI1236_tune(f, f->original_frequency + f->afc_delta);
if (f->last_afc_hint == TUNER_OFF)
return 0;
- return 1; /* call me again */
+ return 1; /* call me again */
}
- return 0; /* done */
+ return 0; /* done */
}
void