Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Miscellany
Wednesday, August 30th, 2006 at 4:14:43pm UTC 

  1. Index: firmware/SOURCES
  2. ===================================================================
  3. RCS file: /cvsroot/rockbox/firmware/SOURCES,v
  4. retrieving revision 1.108
  5. diff -u -r1.108 SOURCES
  6. --- firmware/SOURCES    30 Aug 2006 08:22:29 -0000  1.108
  7. +++ firmware/SOURCES    30 Aug 2006 16:02:08 -0000
  8. @@ -201,10 +201,13 @@
  9.  drivers/uda1380.c
  10.  #elif defined(HAVE_WM8975) && !defined(SIMULATOR)
  11.  drivers/wm8975.c
  12. +drivers/wmcodec-pp.c
  13.  #elif defined(HAVE_WM8758) && !defined(SIMULATOR)
  14.  drivers/wm8758.c
  15. +drivers/wmcodec-pp.c
  16.  #elif (defined(HAVE_WM8731) || defined(HAVE_WM8721)) && !defined(SIMULATOR)
  17.  drivers/wm8731l.c
  18. +drivers/wmcodec-pp.c
  19.  #elif defined(HAVE_TLV320) && !defined(SIMULATOR)
  20.  drivers/tlv320.c
  21.  #endif
  22. Index: firmware/drivers/wm8731l.c
  23. ===================================================================
  24. RCS file: /cvsroot/rockbox/firmware/drivers/wm8731l.c,v
  25. retrieving revision 1.6
  26. diff -u -r1.6 wm8731l.c
  27. --- firmware/drivers/wm8731l.c  30 Aug 2006 00:35:46 -0000        1.6
  28. +++ firmware/drivers/wm8731l.c  30 Aug 2006 16:02:08 -0000
  29. @@ -39,32 +39,19 @@
  30.  
  31.  #include "i2c-pp5002.h"
  32.  #include "wm8731l.h"
  33. -#include "pcf50605.h"
  34.  
  35.  #define IPOD_PCM_LEVEL 0x65       /* -6dB */
  36.  
  37. -void wm8731_write(int reg, int data)
  38. -{
  39. -/* Todo: Since the ipod_i2c_* functions also work on H10 and possibly other PP
  40. -   targets, these functions should probably be renamed */
  41. -#if defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
  42. -    /* The H10's audio codec uses an I2C address of 0x1b */
  43. -    ipod_i2c_send(0x1b, (reg<<1) | ((data&0x100)>>8),data&0xff);
  44. -#else
  45. -    /* The iPod's audio codecs use an I2C address of 0x1a */
  46. -    ipod_i2c_send(0x1a, (reg<<1) | ((data&0x100)>>8),data&0xff);
  47. -#endif
  48. -}
  49.  
  50.  int wmcodec_mute(int mute)
  51.  {
  52.      if (mute)
  53.      {
  54.          /* Set DACMU = 1 to soft-mute the audio DACs. */
  55. -        wm8731_write(DACCTRL, 0x8);
  56. +        wmcodec_write(DACCTRL, 0x8);
  57.      } else {
  58.          /* Set DACMU = 0 to soft-un-mute the audio DACs. */
  59. -        wm8731_write(DACCTRL, 0x0);
  60. +        wmcodec_write(DACCTRL, 0x0);
  61.      }
  62.  
  63.      return 0;
  64. @@ -75,110 +62,12 @@
  65.  {
  66.      /* set active to 0x0 or 0x1 */
  67.      if (active) {
  68. -        wm8731_write(ACTIVECTRL, 0x01);
  69. +        wmcodec_write(ACTIVECTRL, 0x01);
  70.      } else {
  71. -        wm8731_write(ACTIVECTRL, 0x00);
  72. +        wmcodec_write(ACTIVECTRL, 0x00);
  73.      }
  74.  }
  75.  
  76. -/*
  77. - * Reset the I2S BIT.FORMAT I2S, 16bit, FIFO.FORMAT 32bit
  78. - */
  79. -static void i2s_reset(void)
  80. -{
  81. -#if CONFIG_CPU == PP5020
  82. -    /* I2S soft reset */
  83. -    outl(inl(0x70002800) | 0x80000000, 0x70002800);
  84. -    outl(inl(0x70002800) & ~0x80000000, 0x70002800);
  85. -
  86. -    /* BIT.FORMAT [11:10] = I2S (default) */
  87. -    outl(inl(0x70002800) & ~0xc00, 0x70002800);
  88. -    /* BIT.SIZE [9:8] = 16bit (default) */
  89. -    outl(inl(0x70002800) & ~0x300, 0x70002800);
  90. -
  91. -    /* FIFO.FORMAT [6:4] = 32 bit LSB */
  92. -    /* since BIT.SIZ < FIFO.FORMAT low 16 bits will be 0 */
  93. -    outl(inl(0x70002800) | 0x30, 0x70002800);
  94. -
  95. -    /* RX_ATN_LVL=1 == when 12 slots full */
  96. -    /* TX_ATN_LVL=1 == when 12 slots empty */
  97. -    outl(inl(0x7000280c) | 0x33, 0x7000280c);
  98. -
  99. -    /* Rx.CLR = 1, TX.CLR = 1 */
  100. -    outl(inl(0x7000280c) | 0x1100, 0x7000280c);
  101. -#elif CONFIG_CPU == PP5002
  102. -    /* I2S device reset */
  103. -    outl(inl(0xcf005030) | 0x80, 0xcf005030);
  104. -    outl(inl(0xcf005030) & ~0x80, 0xcf005030);
  105. -
  106. -    /* I2S controller enable */
  107. -    outl(inl(0xc0002500) | 0x1, 0xc0002500);
  108. -
  109. -    /* BIT.FORMAT [11:10] = I2S (default) */
  110. -    /* BIT.SIZE [9:8] = 24bit */
  111. -    /* FIFO.FORMAT = 24 bit LSB */
  112. -
  113. -    /* reset DAC and ADC fifo */
  114. -    outl(inl(0xc000251c) | 0x30000, 0xc000251c);
  115. -#endif
  116. -}
  117. -
  118. -/*
  119. - * Initialise the WM8975 for playback via headphone and line out.
  120. - * Note, I'm using the WM8750 datasheet as its apparently close.
  121. - */
  122. -int wmcodec_init(void) {
  123. -    /* reset I2C */
  124. -    i2c_init();
  125. -
  126. -#if CONFIG_CPU == PP5020
  127. -    /* normal outputs for CDI and I2S pin groups */
  128. -    outl(inl(0x70000020) & ~0x300, 0x70000020);
  129. -
  130. -    /*mini2?*/
  131. -    outl(inl(0x70000010) & ~0x3000000, 0x70000010);
  132. -    /*mini2?*/
  133. -
  134. -    /* device reset */
  135. -    outl(inl(0x60006004) | 0x800, 0x60006004);
  136. -    outl(inl(0x60006004) & ~0x800, 0x60006004);
  137. -
  138. -    /* device enable */
  139. -    outl(inl(0x6000600C) | 0x807, 0x6000600C);
  140. -
  141. -    /* enable external dev clock clocks */
  142. -    outl(inl(0x6000600c) | 0x2, 0x6000600c);
  143. -
  144. -    /* external dev clock to 24MHz */
  145. -    outl(inl(0x70000018) & ~0xc, 0x70000018);
  146. -#else
  147. -    /* device reset */
  148. -    outl(inl(0xcf005030) | 0x80, 0xcf005030);
  149. -    outl(inl(0xcf005030) & ~0x80, 0xcf005030);
  150. -
  151. -    /* device enable */
  152. -    outl(inl(0xcf005000) | 0x80, 0xcf005000);
  153. -
  154. -    /* GPIO D06 enable for output */
  155. -    outl(inl(0xcf00000c) | 0x40, 0xcf00000c);
  156. -    outl(inl(0xcf00001c) & ~0x40, 0xcf00001c);
  157. -    /* bits 11,10 == 01 */
  158. -    outl(inl(0xcf004040) | 0x400, 0xcf004040);
  159. -    outl(inl(0xcf004040) & ~0x800, 0xcf004040);
  160. -
  161. -    outl(inl(0xcf004048) & ~0x1, 0xcf004048);
  162. -
  163. -    outl(inl(0xcf000004) & ~0xf, 0xcf000004);
  164. -    outl(inl(0xcf004044) & ~0xf, 0xcf004044);
  165. -
  166. -    /* C03 = 0 */
  167. -    outl(inl(0xcf000008) | 0x8, 0xcf000008);
  168. -    outl(inl(0xcf000018) | 0x8, 0xcf000018);
  169. -    outl(inl(0xcf000028) & ~0x8, 0xcf000028);
  170. -#endif
  171. -   
  172. -    return 0;
  173. -}
  174.  
  175.  /* Silently enable / disable audio output */
  176.  void wmcodec_enable_output(bool enable)
  177. @@ -188,36 +77,36 @@
  178.          /* reset the I2S controller into known state */
  179.          i2s_reset();
  180.  
  181. -        wm8731_write(RESET, 0x0);        /*Reset*/
  182. +        wmcodec_write(RESET, 0x0);        /*Reset*/
  183.  
  184.          codec_set_active(0x0);
  185.  
  186.  #ifdef HAVE_WM8721
  187.          /* DACSEL=1 */
  188. -        wm8731_write(0x4, 0x10);
  189. +        wmcodec_write(0x4, 0x10);
  190.  #elif defined HAVE_WM8731
  191.          /* DACSEL=1, BYPASS=1 */
  192. -        wm8731_write(0x4, 0x18);
  193. +        wmcodec_write(0x4, 0x18);
  194.  #endif
  195.      
  196.          /* set power register to POWEROFF=0 on OUTPD=0, DACPD=0 */
  197. -        wm8731_write(PWRMGMT, 0x67);
  198. +        wmcodec_write(PWRMGMT, 0x67);
  199.  
  200.          /* BCLKINV=0(Dont invert BCLK) MS=1(Enable Master) LRSWAP=0 LRP=0 */
  201.          /* IWL=00(16 bit) FORMAT=10(I2S format) */
  202. -        wm8731_write(AINTFCE, 0x42);
  203. +        wmcodec_write(AINTFCE, 0x42);
  204.  
  205.          wmcodec_set_sample_rate(WM8731L_44100HZ);
  206.  
  207.          /* set the volume to -6dB */
  208. -        wm8731_write(LOUTVOL, IPOD_PCM_LEVEL);
  209. -        wm8731_write(ROUTVOL, 0x100 | IPOD_PCM_LEVEL);
  210. +        wmcodec_write(LOUTVOL, IPOD_PCM_LEVEL);
  211. +        wmcodec_write(ROUTVOL, 0x100 | IPOD_PCM_LEVEL);
  212.  
  213.          /* ACTIVE=1 */
  214.          codec_set_active(1);
  215.  
  216.          /* 5. Set DACMU = 0 to soft-un-mute the audio DACs. */
  217. -        wm8731_write(DACCTRL, 0x0);
  218. +        wmcodec_write(DACCTRL, 0x0);
  219.  
  220.          wmcodec_mute(0);
  221.      } else {
  222. @@ -233,8 +122,8 @@
  223.      /* 0110000 == -73dB */
  224.      /* 0101111 == mute (0x2f) */
  225.  
  226. -    wm8731_write(LOUTVOL, vol_l);
  227. -    wm8731_write(ROUTVOL, vol_r);
  228. +    wmcodec_write(LOUTVOL, vol_l);
  229. +    wmcodec_write(ROUTVOL, vol_r);
  230.  
  231.      return 0;
  232.  }
  233. @@ -261,22 +150,22 @@
  234.  void wmcodec_close(void)
  235.  {
  236.     /* set DACMU=1 DEEMPH=0 */
  237. -    wm8731_write(DACCTRL, 0x8);
  238. +    wmcodec_write(DACCTRL, 0x8);
  239.  
  240.      /* ACTIVE=0 */
  241.      codec_set_active(0x0);
  242.  
  243.      /* line in mute left & right*/
  244. -    wm8731_write(LINVOL, 0x100 | 0x80);
  245. +    wmcodec_write(LINVOL, 0x100 | 0x80);
  246.  
  247.      /* set DACSEL=0, MUTEMIC=1 */
  248. -    wm8731_write(0x4, 0x2);
  249. +    wmcodec_write(0x4, 0x2);
  250.  
  251.      /* set POWEROFF=0 OUTPD=0 DACPD=1 */
  252. -    wm8731_write(PWRMGMT, 0x6f);
  253. +    wmcodec_write(PWRMGMT, 0x6f);
  254.  
  255.      /* set POWEROFF=1 OUTPD=1 DACPD=1 */
  256. -    wm8731_write(PWRMGMT, 0xff);
  257. +    wmcodec_write(PWRMGMT, 0xff);
  258.  }
  259.  
  260.  /* Change the order of the noise shaper, 5th order is recommended above 32kHz */
  261. @@ -288,7 +177,7 @@
  262.  void wmcodec_set_sample_rate(int sampling_control)
  263.  {
  264.      codec_set_active(0x0);
  265. -    wm8731_write(SAMPCTRL, sampling_control);
  266. +    wmcodec_write(SAMPCTRL, sampling_control);
  267.      codec_set_active(0x1);
  268.  }
  269.  
  270. Index: firmware/drivers/wm8758.c
  271. ===================================================================
  272. RCS file: /cvsroot/rockbox/firmware/drivers/wm8758.c,v
  273. retrieving revision 1.11
  274. diff -u -r1.11 wm8758.c
  275. --- firmware/drivers/wm8758.c   15 Aug 2006 09:38:13 -0000 1.11
  276. +++ firmware/drivers/wm8758.c   30 Aug 2006 16:02:08 -0000
  277. @@ -37,9 +37,7 @@
  278.  #include "buffer.h"
  279.  #include "audio.h"
  280.  
  281. -#include "i2c-pp5020.h"
  282.  #include "wm8758.h"
  283. -#include "pcf50605.h"
  284.  
  285.  void wmcodec_reset(void);
  286.  
  287. @@ -48,67 +46,6 @@
  288.  //#define BASSCTRL   0x
  289.  //#define TREBCTRL   0x0b
  290.  
  291. -/*
  292. - * Reset the I2S BIT.FORMAT I2S, 16bit, FIFO.FORMAT 32bit
  293. - */
  294. -static void i2s_reset(void)
  295. -{
  296. -    /* PP502x */
  297. -
  298. -    /* I2S soft reset */
  299. -    outl(inl(0x70002800) | 0x80000000, 0x70002800);
  300. -    outl(inl(0x70002800) & ~0x80000000, 0x70002800);
  301. -
  302. -    /* BIT.FORMAT [11:10] = I2S (default) */
  303. -    outl(inl(0x70002800) & ~0xc00, 0x70002800);
  304. -    /* BIT.SIZE [9:8] = 16bit (default) */
  305. -    outl(inl(0x70002800) & ~0x300, 0x70002800);
  306. -
  307. -    /* FIFO.FORMAT [6:4] = 32 bit LSB */
  308. -    /* since BIT.SIZ < FIFO.FORMAT low 16 bits will be 0 */
  309. -    outl(inl(0x70002800) | 0x30, 0x70002800);
  310. -
  311. -    /* RX_ATN_LVL=1 == when 12 slots full */
  312. -    /* TX_ATN_LVL=1 == when 12 slots empty */
  313. -    outl(inl(0x7000280c) | 0x33, 0x7000280c);
  314. -
  315. -    /* Rx.CLR = 1, TX.CLR = 1 */
  316. -    outl(inl(0x7000280c) | 0x1100, 0x7000280c);
  317. -}
  318. -
  319. -void wm8758_write(int reg, int data)
  320. -{
  321. -    ipod_i2c_send(0x1a, (reg<<1) | ((data&0x100)>>8),data&0xff);
  322. -}
  323. -
  324. -/*
  325. - * Initialise the WM8758 for playback via headphone and line out.
  326. - * Note, I'm using the WM8750 datasheet as its apparently close.
  327. - */
  328. -int wmcodec_init(void) {
  329. -    /* normal outputs for CDI and I2S pin groups */
  330. -    outl(inl(0x70000020) & ~0x300, 0x70000020);
  331. -
  332. -    /*mini2?*/
  333. -    outl(inl(0x70000010) & ~0x3000000, 0x70000010);
  334. -    /*mini2?*/
  335. -
  336. -    /* device reset */
  337. -    outl(inl(0x60006004) | 0x800, 0x60006004);
  338. -    outl(inl(0x60006004) & ~0x800, 0x60006004);
  339. -
  340. -    /* device enable */
  341. -    outl(inl(0x6000600C) | 0x807, 0x6000600C);
  342. -
  343. -    /* enable external dev clock clocks */
  344. -    outl(inl(0x6000600c) | 0x2, 0x6000600c);
  345. -
  346. -    /* external dev clock to 24MHz */
  347. -    outl(inl(0x70000018) & ~0xc, 0x70000018);
  348. -
  349. -    return 0;
  350. -}
  351. -
  352.  /* Silently enable / disable audio output */
  353.  void wmcodec_enable_output(bool enable)
  354.  {
  355. @@ -119,23 +56,23 @@
  356.  
  357.          /* TODO: Review the power-up sequence to prevent pops */
  358.  
  359. -        wm8758_write(RESET, 0x1ff);    /*Reset*/
  360. +        wmcodec_write(RESET, 0x1ff);    /*Reset*/
  361.      
  362. -        wm8758_write(PWRMGMT1, 0x2b);
  363. -        wm8758_write(PWRMGMT2, 0x180);
  364. -        wm8758_write(PWRMGMT3, 0x6f);
  365. +        wmcodec_write(PWRMGMT1, 0x2b);
  366. +        wmcodec_write(PWRMGMT2, 0x180);
  367. +        wmcodec_write(PWRMGMT3, 0x6f);
  368.  
  369. -        wm8758_write(AINTFCE, 0x10);
  370. -        wm8758_write(CLKCTRL, 0x49);
  371. +        wmcodec_write(AINTFCE, 0x10);
  372. +        wmcodec_write(CLKCTRL, 0x49);
  373.  
  374. -        wm8758_write(OUTCTRL, 1);
  375. +        wmcodec_write(OUTCTRL, 1);
  376.  
  377.          /* The iPod can handle multiple frequencies, but fix at 44.1KHz
  378.             for now */
  379.          wmcodec_set_sample_rate(WM8758_44100HZ);
  380.      
  381. -        wm8758_write(LOUTMIX,0x1); /* Enable mixer */
  382. -        wm8758_write(ROUTMIX,0x1); /* Enable mixer */
  383. +        wmcodec_write(LOUTMIX,0x1); /* Enable mixer */
  384. +        wmcodec_write(ROUTMIX,0x1); /* Enable mixer */
  385.          wmcodec_mute(0);
  386.      } else {
  387.          wmcodec_mute(1);
  388. @@ -145,8 +82,8 @@
  389.  int wmcodec_set_master_vol(int vol_l, int vol_r)
  390.  {
  391.      /* OUT1 */
  392. -    wm8758_write(LOUT1VOL, 0x080 | vol_l);
  393. -    wm8758_write(ROUT1VOL, 0x180 | vol_r);
  394. +    wmcodec_write(LOUT1VOL, 0x080 | vol_l);
  395. +    wmcodec_write(ROUT1VOL, 0x180 | vol_r);
  396.  
  397.      return 0;
  398.  }
  399. @@ -154,8 +91,8 @@
  400.  int wmcodec_set_lineout_vol(int vol_l, int vol_r)
  401.  {
  402.      /* OUT2 */
  403. -    wm8758_write(LOUT2VOL, vol_l);
  404. -    wm8758_write(ROUT2VOL, 0x100 | vol_r);
  405. +    wmcodec_write(LOUT2VOL, vol_l);
  406. +    wmcodec_write(ROUT2VOL, 0x100 | vol_r);
  407.      
  408.      return 0;
  409.  }
  410. @@ -178,7 +115,7 @@
  411.  
  412.      if ((value >= -6) && (value <= 9)) {
  413.          /* We use linear bass control with 130Hz cutoff */
  414. -        wm8758_write(BASSCTRL, regvalues[value+6]);
  415. +        wmcodec_write(BASSCTRL, regvalues[value+6]);
  416.      }
  417.  #endif
  418.  }
  419. @@ -192,7 +129,7 @@
  420.  
  421.      if ((value >= -6) && (value <= 9)) {
  422.          /* We use a 8Khz cutoff */
  423. -        wm8758_write(TREBCTRL, regvalues[value+6]);
  424. +        wmcodec_write(TREBCTRL, regvalues[value+6]);
  425.      }
  426.  #endif
  427.  
  428. @@ -203,10 +140,10 @@
  429.      if (mute)
  430.      {
  431.          /* Set DACMU = 1 to soft-mute the audio DACs. */
  432. -        wm8758_write(DACCTRL, 0x40);
  433. +        wmcodec_write(DACCTRL, 0x40);
  434.      } else {
  435.          /* Set DACMU = 0 to soft-un-mute the audio DACs. */
  436. -        wm8758_write(DACCTRL, 0x0);
  437. +        wmcodec_write(DACCTRL, 0x0);
  438.      }
  439.  
  440.      return 0;
  441. @@ -217,11 +154,11 @@
  442.  {
  443.      wmcodec_mute(1);
  444.  
  445. -    wm8758_write(PWRMGMT3, 0x0);
  446. +    wmcodec_write(PWRMGMT3, 0x0);
  447.  
  448. -    wm8758_write(PWRMGMT1, 0x0);
  449. +    wmcodec_write(PWRMGMT1, 0x0);
  450.  
  451. -    wm8758_write(PWRMGMT2, 0x40);
  452. +    wmcodec_write(PWRMGMT2, 0x40);
  453.  }
  454.  
  455.  /* Change the order of the noise shaper, 5th order is recommended above 32kHz */
  456. @@ -237,19 +174,19 @@
  457.      (void)sampling_control;
  458.  
  459.      /* set clock div */
  460. -    wm8758_write(CLKCTRL, 1 | (0 << 2) | (2 << 5));
  461. +    wmcodec_write(CLKCTRL, 1 | (0 << 2) | (2 << 5));
  462.  
  463.      /* setup PLL for MHZ=11.2896 */
  464. -    wm8758_write(PLLN, (1 << 4) | 0x7);
  465. -    wm8758_write(PLLK1, 0x21);
  466. -    wm8758_write(PLLK2, 0x161);
  467. -    wm8758_write(PLLK3, 0x26);
  468. +    wmcodec_write(PLLN, (1 << 4) | 0x7);
  469. +    wmcodec_write(PLLK1, 0x21);
  470. +    wmcodec_write(PLLK2, 0x161);
  471. +    wmcodec_write(PLLK3, 0x26);
  472.  
  473.      /* set clock div */
  474. -    wm8758_write(CLKCTRL, 1 | (1 << 2) | (2 << 5) | (1 << 8));
  475. +    wmcodec_write(CLKCTRL, 1 | (1 << 2) | (2 << 5) | (1 << 8));
  476.  
  477.      /* set srate */
  478. -    wm8758_write(SRATECTRL, (0 << 1));
  479. +    wmcodec_write(SRATECTRL, (0 << 1));
  480.  }
  481.  
  482.  void wmcodec_enable_recording(bool source_mic)
  483. @@ -286,14 +223,14 @@
  484.      eq |= 12 - gain;
  485.  
  486.      if (band == 0) {
  487. -        wm8758_write(EQ1, eq | 0x100); /* Always apply EQ to the DAC path */
  488. +        wmcodec_write(EQ1, eq | 0x100); /* Always apply EQ to the DAC path */
  489.      } else if (band == 1) {
  490. -        wm8758_write(EQ2, eq);
  491. +        wmcodec_write(EQ2, eq);
  492.      } else if (band == 2) {
  493. -        wm8758_write(EQ3, eq);
  494. +        wmcodec_write(EQ3, eq);
  495.      } else if (band == 3) {
  496. -        wm8758_write(EQ4, eq);
  497. +        wmcodec_write(EQ4, eq);
  498.      } else if (band == 4) {
  499. -        wm8758_write(EQ5, eq);
  500. +        wmcodec_write(EQ5, eq);
  501.      }
  502.  }
  503. Index: firmware/drivers/wm8975.c
  504. ===================================================================
  505. RCS file: /cvsroot/rockbox/firmware/drivers/wm8975.c,v
  506. retrieving revision 1.7
  507. diff -u -r1.7 wm8975.c
  508. --- firmware/drivers/wm8975.c   22 Mar 2006 13:04:49 -0000 1.7
  509. +++ firmware/drivers/wm8975.c   30 Aug 2006 16:02:08 -0000
  510. @@ -37,77 +37,12 @@
  511.  #include "buffer.h"
  512.  #include "audio.h"
  513.  
  514. -#include "i2c-pp5020.h"
  515.  #include "wm8975.h"
  516. -#include "pcf50605.h"
  517.  
  518.  void wmcodec_reset(void);
  519.  
  520.  #define IPOD_PCM_LEVEL 0x65       /* -6dB */
  521.  
  522. -/*
  523. - * Reset the I2S BIT.FORMAT I2S, 16bit, FIFO.FORMAT 32bit
  524. - */
  525. -static void i2s_reset(void)
  526. -{
  527. -    /* PP502x */
  528. -
  529. -    /* I2S soft reset */
  530. -    outl(inl(0x70002800) | 0x80000000, 0x70002800);
  531. -    outl(inl(0x70002800) & ~0x80000000, 0x70002800);
  532. -
  533. -    /* BIT.FORMAT [11:10] = I2S (default) */
  534. -    outl(inl(0x70002800) & ~0xc00, 0x70002800);
  535. -    /* BIT.SIZE [9:8] = 16bit (default) */
  536. -    outl(inl(0x70002800) & ~0x300, 0x70002800);
  537. -
  538. -    /* FIFO.FORMAT [6:4] = 32 bit LSB */
  539. -    /* since BIT.SIZ < FIFO.FORMAT low 16 bits will be 0 */
  540. -    outl(inl(0x70002800) | 0x30, 0x70002800);
  541. -
  542. -    /* RX_ATN_LVL=1 == when 12 slots full */
  543. -    /* TX_ATN_LVL=1 == when 12 slots empty */
  544. -    outl(inl(0x7000280c) | 0x33, 0x7000280c);
  545. -
  546. -    /* Rx.CLR = 1, TX.CLR = 1 */
  547. -    outl(inl(0x7000280c) | 0x1100, 0x7000280c);
  548. -}
  549. -
  550. -void wm8975_write(int reg, int data)
  551. -{
  552. -    ipod_i2c_send(0x1a, (reg<<1) | ((data&0x100)>>8),data&0xff);
  553. -}
  554. -
  555. -/*
  556. - * Initialise the WM8975 for playback via headphone and line out.
  557. - * Note, I'm using the WM8750 datasheet as its apparently close.
  558. - */
  559. -int wmcodec_init(void) {
  560. -    /* reset I2C */
  561. -    i2c_init();
  562. -
  563. -    /* normal outputs for CDI and I2S pin groups */
  564. -    outl(inl(0x70000020) & ~0x300, 0x70000020);
  565. -
  566. -    /*mini2?*/
  567. -    outl(inl(0x70000010) & ~0x3000000, 0x70000010);
  568. -    /*mini2?*/
  569. -
  570. -    /* device reset */
  571. -    outl(inl(0x60006004) | 0x800, 0x60006004);
  572. -    outl(inl(0x60006004) & ~0x800, 0x60006004);
  573. -
  574. -    /* device enable */
  575. -    outl(inl(0x6000600C) | 0x807, 0x6000600C);
  576. -
  577. -    /* enable external dev clock clocks */
  578. -    outl(inl(0x6000600c) | 0x2, 0x6000600c);
  579. -
  580. -    /* external dev clock to 24MHz */
  581. -    outl(inl(0x70000018) & ~0xc, 0x70000018);
  582. -
  583. -    return 0;
  584. -}
  585.  
  586.  /* Silently enable / disable audio output */
  587.  void wmcodec_enable_output(bool enable)
  588. @@ -124,39 +59,39 @@
  589.           *    and Headphone outputs are all OFF (DACMU = 1 Power
  590.           *    Management registers 1 and 2 are all zeros).
  591.           */
  592. -        wm8975_write(RESET, 0x1ff);    /*Reset*/
  593. -        wm8975_write(RESET, 0x0);
  594. +        wmcodec_write(RESET, 0x1ff);    /*Reset*/
  595. +        wmcodec_write(RESET, 0x0);
  596.      
  597.           /* 2. Enable Vmid and VREF. */
  598. -        wm8975_write(PWRMGMT1, 0xc0);    /*Pwr Mgmt(1)*/
  599. +        wmcodec_write(PWRMGMT1, 0xc0);    /*Pwr Mgmt(1)*/
  600.      
  601.           /* 3. Enable DACs as required. */
  602. -        wm8975_write(PWRMGMT2, 0x180);    /*Pwr Mgmt(2)*/
  603. +        wmcodec_write(PWRMGMT2, 0x180);    /*Pwr Mgmt(2)*/
  604.      
  605.           /* 4. Enable line and / or headphone output buffers as required. */
  606. -        wm8975_write(PWRMGMT2, 0x1f8);    /*Pwr Mgmt(2)*/
  607. +        wmcodec_write(PWRMGMT2, 0x1f8);    /*Pwr Mgmt(2)*/
  608.      
  609.          /* BCLKINV=0(Dont invert BCLK) MS=1(Enable Master) LRSWAP=0 LRP=0 */
  610.          /* IWL=00(16 bit) FORMAT=10(I2S format) */
  611. -        wm8975_write(AINTFCE, 0x42);
  612. +        wmcodec_write(AINTFCE, 0x42);
  613.      
  614.          /* The iPod can handle multiple frequencies, but fix at 44.1KHz for now */
  615.          wmcodec_set_sample_rate(WM8975_44100HZ);
  616.      
  617.          /* set the volume to -6dB */
  618. -        wm8975_write(LOUT1VOL, IPOD_PCM_LEVEL);
  619. -        wm8975_write(ROUT1VOL,0x100 | IPOD_PCM_LEVEL);
  620. -        wm8975_write(LOUT1VOL, IPOD_PCM_LEVEL);
  621. -        wm8975_write(ROUT1VOL,0x100 | IPOD_PCM_LEVEL);
  622. +        wmcodec_write(LOUT1VOL, IPOD_PCM_LEVEL);
  623. +        wmcodec_write(ROUT1VOL,0x100 | IPOD_PCM_LEVEL);
  624. +        wmcodec_write(LOUT1VOL, IPOD_PCM_LEVEL);
  625. +        wmcodec_write(ROUT1VOL,0x100 | IPOD_PCM_LEVEL);
  626.  
  627. -        wm8975_write(LOUTMIX1, 0x150);    /* Left out Mix(def) */
  628. -        wm8975_write(LOUTMIX2, 0x50);
  629. +        wmcodec_write(LOUTMIX1, 0x150);    /* Left out Mix(def) */
  630. +        wmcodec_write(LOUTMIX2, 0x50);
  631.      
  632. -        wm8975_write(ROUTMIX1, 0x50);    /* Right out Mix(def) */
  633. -        wm8975_write(ROUTMIX2, 0x150);
  634. +        wmcodec_write(ROUTMIX1, 0x50);    /* Right out Mix(def) */
  635. +        wmcodec_write(ROUTMIX2, 0x150);
  636.      
  637. -        wm8975_write(MOUTMIX1, 0x0);     /* Mono out Mix */
  638. -        wm8975_write(MOUTMIX2, 0x0);
  639. +        wmcodec_write(MOUTMIX1, 0x0);     /* Mono out Mix */
  640. +        wmcodec_write(MOUTMIX2, 0x0);
  641.  
  642.          wmcodec_mute(0);
  643.      } else {
  644. @@ -173,8 +108,8 @@
  645.      /* 0101111 == mute (0x2f) */
  646.  
  647.      /* OUT1 */
  648. -    wm8975_write(LOUT1VOL, vol_l);
  649. -    wm8975_write(ROUT1VOL, 0x100 | vol_r);
  650. +    wmcodec_write(LOUT1VOL, vol_l);
  651. +    wmcodec_write(ROUT1VOL, 0x100 | vol_r);
  652.  
  653.      return 0;
  654.  }
  655. @@ -182,8 +117,8 @@
  656.  int wmcodec_set_lineout_vol(int vol_l, int vol_r)
  657.  {
  658.      /* OUT2 */
  659. -    wm8975_write(LOUT2VOL, vol_l);
  660. -    wm8975_write(ROUT2VOL, 0x100 | vol_r);
  661. +    wmcodec_write(LOUT2VOL, vol_l);
  662. +    wmcodec_write(ROUT2VOL, 0x100 | vol_r);
  663.  
  664.      return 0;
  665.  }
  666. @@ -203,7 +138,7 @@
  667.  
  668.    if ((value >= -6) && (value <= 9)) {
  669.        /* We use linear bass control with 130Hz cutoff */
  670. -      wm8975_write(BASSCTRL, regvalues[value+6]);
  671. +      wmcodec_write(BASSCTRL, regvalues[value+6]);
  672.    }
  673.  }
  674.  
  675. @@ -213,7 +148,7 @@
  676.  
  677.    if ((value >= -6) && (value <= 9)) {
  678.        /* We use a 8Khz cutoff */
  679. -      wm8975_write(TREBCTRL, regvalues[value+6]);
  680. +      wmcodec_write(TREBCTRL, regvalues[value+6]);
  681.    }
  682.  }
  683.  
  684. @@ -222,10 +157,10 @@
  685.      if (mute)
  686.      {
  687.          /* Set DACMU = 1 to soft-mute the audio DACs. */
  688. -        wm8975_write(DACCTRL, 0x8);
  689. +        wmcodec_write(DACCTRL, 0x8);
  690.      } else {
  691.          /* Set DACMU = 0 to soft-un-mute the audio DACs. */
  692. -        wm8975_write(DACCTRL, 0x0);
  693. +        wmcodec_write(DACCTRL, 0x0);
  694.      }
  695.  
  696.      return 0;
  697. @@ -235,13 +170,13 @@
  698.  void wmcodec_close(void)
  699.  {
  700.      /* 1. Set DACMU = 1 to soft-mute the audio DACs. */
  701. -    wm8975_write(DACCTRL, 0x8);
  702. +    wmcodec_write(DACCTRL, 0x8);
  703.  
  704.      /* 2. Disable all output buffers. */
  705. -    wm8975_write(PWRMGMT2, 0x0);     /*Pwr Mgmt(2)*/
  706. +    wmcodec_write(PWRMGMT2, 0x0);     /*Pwr Mgmt(2)*/
  707.  
  708.      /* 3. Switch off the power supplies. */
  709. -    wm8975_write(PWRMGMT1, 0x0);     /*Pwr Mgmt(1)*/
  710. +    wmcodec_write(PWRMGMT1, 0x0);     /*Pwr Mgmt(1)*/
  711.  }
  712.  
  713.  /* Change the order of the noise shaper, 5th order is recommended above 32kHz */
  714. @@ -253,7 +188,7 @@
  715.  /* Note: Disable output before calling this function */
  716.  void wmcodec_set_sample_rate(int sampling_control) {
  717.  
  718. -  wm8975_write(0x08, sampling_control);
  719. +  wmcodec_write(0x08, sampling_control);
  720.  
  721.  }
  722.  
  723. Index: firmware/drivers/wmcodec-pp.c
  724. ===================================================================
  725. RCS file: firmware/drivers/wmcodec-pp.c
  726. diff -N firmware/drivers/wmcodec-pp.c
  727. --- /dev/null   1 Jan 1970 00:00:00 -0000
  728. +++ firmware/drivers/wmcodec-pp.c       30 Aug 2006 16:02:08 -0000
  729. @@ -0,0 +1,157 @@
  730. +/***************************************************************************
  731. + *             __________               __   ___.
  732. + *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
  733. + *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
  734. + *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
  735. + *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
  736. + *                     \/            \/     \/    \/            \/
  737. + * $Id: wm8975.c,v 1.7 2006-03-22 13:04:49 preglow Exp $
  738. + *
  739. + * Driver for WM8975 audio codec
  740. + *
  741. + * Based on code from the ipodlinux project - http://ipodlinux.org/
  742. + * Adapted for Rockbox in December 2005
  743. + *
  744. + * Original file: linux/arch/armnommu/mach-ipod/audio.c
  745. + *
  746. + * Copyright (c) 2003-2005 Bernard Leach ([email protected])
  747. + *
  748. + * All files in this archive are subject to the GNU General Public License.
  749. + * See the file COPYING in the source tree root for full license agreement.
  750. + *
  751. + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  752. + * KIND, either express or implied.
  753. + *
  754. + ****************************************************************************/
  755. +#include "lcd.h"
  756. +#include "cpu.h"
  757. +#include "kernel.h"
  758. +#include "thread.h"
  759. +#include "power.h"
  760. +#include "debug.h"
  761. +#include "system.h"
  762. +#include "sprintf.h"
  763. +#include "button.h"
  764. +#include "string.h"
  765. +#include "file.h"
  766. +#include "buffer.h"
  767. +#include "audio.h"
  768. +
  769. +#if CONFIG_CPU == PP5020
  770. +#include "i2c-pp5020.h"
  771. +#elif CONFIG_CPU == PP5002
  772. +#include "i2c-pp5002.h"
  773. +#endif
  774. +
  775. +/*
  776. + * Reset the I2S BIT.FORMAT I2S, 16bit, FIFO.FORMAT 32bit
  777. + */
  778. +void i2s_reset(void)
  779. +{
  780. +#if CONFIG_CPU == PP5020
  781. +    /* I2S soft reset */
  782. +    outl(inl(0x70002800) | 0x80000000, 0x70002800);
  783. +    outl(inl(0x70002800) & ~0x80000000, 0x70002800);
  784. +
  785. +    /* BIT.FORMAT [11:10] = I2S (default) */
  786. +    outl(inl(0x70002800) & ~0xc00, 0x70002800);
  787. +    /* BIT.SIZE [9:8] = 16bit (default) */
  788. +    outl(inl(0x70002800) & ~0x300, 0x70002800);
  789. +
  790. +    /* FIFO.FORMAT [6:4] = 32 bit LSB */
  791. +    /* since BIT.SIZ < FIFO.FORMAT low 16 bits will be 0 */
  792. +    outl(inl(0x70002800) | 0x30, 0x70002800);
  793. +
  794. +    /* RX_ATN_LVL=1 == when 12 slots full */
  795. +    /* TX_ATN_LVL=1 == when 12 slots empty */
  796. +    outl(inl(0x7000280c) | 0x33, 0x7000280c);
  797. +
  798. +    /* Rx.CLR = 1, TX.CLR = 1 */
  799. +    outl(inl(0x7000280c) | 0x1100, 0x7000280c);
  800. +#elif CONFIG_CPU == PP5002
  801. +    /* I2S device reset */
  802. +    outl(inl(0xcf005030) | 0x80, 0xcf005030);
  803. +    outl(inl(0xcf005030) & ~0x80, 0xcf005030);
  804. +
  805. +    /* I2S controller enable */
  806. +    outl(inl(0xc0002500) | 0x1, 0xc0002500);
  807. +
  808. +    /* BIT.FORMAT [11:10] = I2S (default) */
  809. +    /* BIT.SIZE [9:8] = 24bit */
  810. +    /* FIFO.FORMAT = 24 bit LSB */
  811. +
  812. +    /* reset DAC and ADC fifo */
  813. +    outl(inl(0xc000251c) | 0x30000, 0xc000251c);
  814. +#endif
  815. +}
  816. +
  817. +/*
  818. + * Initialise the WM8975 for playback via headphone and line out.
  819. + * Note, I'm using the WM8750 datasheet as its apparently close.
  820. + */
  821. +int wmcodec_init(void) {
  822. +    /* reset I2C */
  823. +    i2c_init();
  824. +
  825. +#if CONFIG_CPU == PP5020
  826. +    /* normal outputs for CDI and I2S pin groups */
  827. +    outl(inl(0x70000020) & ~0x300, 0x70000020);
  828. +
  829. +    /*mini2?*/
  830. +    outl(inl(0x70000010) & ~0x3000000, 0x70000010);
  831. +    /*mini2?*/
  832. +
  833. +    /* device reset */
  834. +    outl(inl(0x60006004) | 0x800, 0x60006004);
  835. +    outl(inl(0x60006004) & ~0x800, 0x60006004);
  836. +
  837. +    /* device enable */
  838. +    outl(inl(0x6000600C) | 0x807, 0x6000600C);
  839. +
  840. +    /* enable external dev clock clocks */
  841. +    outl(inl(0x6000600c) | 0x2, 0x6000600c);
  842. +
  843. +    /* external dev clock to 24MHz */
  844. +    outl(inl(0x70000018) & ~0xc, 0x70000018);
  845. +#else
  846. +    /* device reset */
  847. +    outl(inl(0xcf005030) | 0x80, 0xcf005030);
  848. +    outl(inl(0xcf005030) & ~0x80, 0xcf005030);
  849. +
  850. +    /* device enable */
  851. +    outl(inl(0xcf005000) | 0x80, 0xcf005000);
  852. +
  853. +    /* GPIO D06 enable for output */
  854. +    outl(inl(0xcf00000c) | 0x40, 0xcf00000c);
  855. +    outl(inl(0xcf00001c) & ~0x40, 0xcf00001c);
  856. +    /* bits 11,10 == 01 */
  857. +    outl(inl(0xcf004040) | 0x400, 0xcf004040);
  858. +    outl(inl(0xcf004040) & ~0x800, 0xcf004040);
  859. +
  860. +    outl(inl(0xcf004048) & ~0x1, 0xcf004048);
  861. +
  862. +    outl(inl(0xcf000004) & ~0xf, 0xcf000004);
  863. +    outl(inl(0xcf004044) & ~0xf, 0xcf004044);
  864. +
  865. +    /* C03 = 0 */
  866. +    outl(inl(0xcf000008) | 0x8, 0xcf000008);
  867. +    outl(inl(0xcf000018) | 0x8, 0xcf000018);
  868. +    outl(inl(0xcf000028) & ~0x8, 0xcf000028);
  869. +#endif
  870. +   
  871. +    return 0;
  872. +}
  873. +
  874. +void wmcodec_write(int reg, int data)
  875. +{
  876. +    /* Todo: Since the ipod_i2c_* functions also work on H10 and possibly other PP
  877. +       targets, these functions should probably be renamed */
  878. +#if defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
  879. +    /* The H10's audio codec uses an I2C address of 0x1b */
  880. +    ipod_i2c_send(0x1b, (reg<<1) | ((data&0x100)>>8),data&0xff);
  881. +#else
  882. +    /* The iPod's audio codecs use an I2C address of 0x1a */
  883. +    ipod_i2c_send(0x1a, (reg<<1) | ((data&0x100)>>8),data&0xff);
  884. +#endif
  885. +}
  886. +

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

comments powered by Disqus
worth-right
worth-right
worth-right