On Sun, Apr 04, 2010 at 04:35:53PM -0400, Brad wrote:
> Here is a diff to copy over a few of the changes made to snapper(4)
> by todd@ and jakemsr@ awhile ago over to tumbler(4). As you can
> see it has been sitting for awhile. I haven't had relevent hw
> in quite some time, so instead of this sitting on my hd for longer
> I'm sending this out for testing and so it'll get commited.
> 
> 
> - set init data to match tumbler_set_foo*
> - implement proper volume control table based on chipset docs
> - set volume to 190 (audible compared to the default)
> - for outputs.{bass,treble}, 0 dB corresponds to mixer value 128,
>   not 0.

Thanks to nicm@ for pointing out a typo..

 
Index: tumbler.c
===================================================================
RCS file: /cvs/src/sys/arch/macppc/dev/tumbler.c,v
retrieving revision 1.6
diff -u -p -r1.6 tumbler.c
--- tumbler.c   29 Oct 2008 00:04:14 -0000      1.6
+++ tumbler.c   6 Nov 2008 10:22:40 -0000
@@ -193,6 +193,162 @@ const uint8_t tumbler_basstab[] = {
        0x01,   /* 18dB */
 };
 
+struct {
+       int high, mid, low;
+} tumbler_volumetab[] = {
+       { 0x07, 0xF1, 0x7B }, /* 18.0 */
+       { 0x07, 0x7F, 0xBB }, /* 17.5 */
+       { 0x07, 0x14, 0x57 }, /* 17.0 */
+       { 0x06, 0xAE, 0xF6 }, /* 16.5 */
+       { 0x06, 0x4F, 0x40 }, /* 16.0 */
+       { 0x05, 0xF4, 0xE5 }, /* 15.5 */
+       { 0x05, 0x9F, 0x98 }, /* 15.0 */
+       { 0x05, 0x4F, 0x10 }, /* 14.5 */
+       { 0x05, 0x03, 0x0A }, /* 14.0 */
+       { 0x04, 0xBB, 0x44 }, /* 13.5 */
+       { 0x04, 0x77, 0x83 }, /* 13.0 */
+       { 0x04, 0x37, 0x8B }, /* 12.5 */
+       { 0x03, 0xFB, 0x28 }, /* 12.0 */
+       { 0x03, 0xC2, 0x25 }, /* 11.5 */
+       { 0x03, 0x8C, 0x53 }, /* 11.0 */
+       { 0x03, 0x59, 0x83 }, /* 10.5 */
+       { 0x03, 0x29, 0x8B }, /* 10.0 */
+       { 0x02, 0xFC, 0x42 }, /* 9.5 */
+       { 0x02, 0xD1, 0x82 }, /* 9.0 */
+       { 0x02, 0xA9, 0x25 }, /* 8.5 */
+       { 0x02, 0x83, 0x0B }, /* 8.0 */
+       { 0x02, 0x5F, 0x12 }, /* 7.5 */
+       { 0x02, 0x3D, 0x1D }, /* 7.0 */
+       { 0x02, 0x1D, 0x0E }, /* 6.5 */
+       { 0x01, 0xFE, 0xCA }, /* 6.0 */
+       { 0x01, 0xE2, 0x37 }, /* 5.5 */
+       { 0x01, 0xC7, 0x3D }, /* 5.0 */
+       { 0x01, 0xAD, 0xC6 }, /* 4.5 */
+       { 0x01, 0x95, 0xBC }, /* 4.0 */
+       { 0x01, 0x7F, 0x09 }, /* 3.5 */
+       { 0x01, 0x69, 0x9C }, /* 3.0 */
+       { 0x01, 0x55, 0x62 }, /* 2.5 */
+       { 0x01, 0x42, 0x49 }, /* 2.0 */
+       { 0x01, 0x30, 0x42 }, /* 1.5 */
+       { 0x01, 0x1F, 0x3D }, /* 1.0 */
+       { 0x01, 0x0F, 0x2B }, /* 0.5 */
+       { 0x01, 0x00, 0x00 }, /* 0.0 */
+       { 0x00, 0xF1, 0xAE }, /* -0.5 */
+       { 0x00, 0xE4, 0x29 }, /* -1.0 */
+       { 0x00, 0xD7, 0x66 }, /* -1.5 */
+       { 0x00, 0xCB, 0x59 }, /* -2.0 */
+       { 0x00, 0xBF, 0xF9 }, /* -2.5 */
+       { 0x00, 0xB5, 0x3C }, /* -3.0 */
+       { 0x00, 0xAB, 0x19 }, /* -3.5 */
+       { 0x00, 0xA1, 0x86 }, /* -4.0 */
+       { 0x00, 0x98, 0x7D }, /* -4.5 */
+       { 0x00, 0x8F, 0xF6 }, /* -5.0 */
+       { 0x00, 0x87, 0xE8 }, /* -5.5 */
+       { 0x00, 0x80, 0x4E }, /* -6.0 */
+       { 0x00, 0x79, 0x20 }, /* -6.5 */
+       { 0x00, 0x72, 0x5A }, /* -7.0 */
+       { 0x00, 0x6B, 0xF4 }, /* -7.5 */
+       { 0x00, 0x65, 0xEA }, /* -8.0 */
+       { 0x00, 0x60, 0x37 }, /* -8.5 */
+       { 0x00, 0x5A, 0xD5 }, /* -9.0 */
+       { 0x00, 0x55, 0xC0 }, /* -9.5 */
+       { 0x00, 0x50, 0xF4 }, /* -10.0 */
+       { 0x00, 0x4C, 0x6D }, /* -10.5 */
+       { 0x00, 0x48, 0x27 }, /* -11.0 */
+       { 0x00, 0x44, 0x1D }, /* -11.5 */
+       { 0x00, 0x40, 0x4E }, /* -12.0 */
+       { 0x00, 0x3C, 0xB5 }, /* -12.5 */
+       { 0x00, 0x39, 0x50 }, /* -13.0 */
+       { 0x00, 0x36, 0x1B }, /* -13.5 */
+       { 0x00, 0x33, 0x14 }, /* -14.0 */
+       { 0x00, 0x30, 0x39 }, /* -14.5 */
+       { 0x00, 0x2D, 0x86 }, /* -15.0 */
+       { 0x00, 0x2A, 0xFA }, /* -15.5 */
+       { 0x00, 0x28, 0x93 }, /* -16.0 */
+       { 0x00, 0x26, 0x4E }, /* -16.5 */
+       { 0x00, 0x24, 0x29 }, /* -17.0 */
+       { 0x00, 0x22, 0x23 }, /* -17.5 */
+       { 0x00, 0x20, 0x3A }, /* -18.0 */
+       { 0x00, 0x1E, 0x6D }, /* -18.5 */
+       { 0x00, 0x1C, 0xB9 }, /* -19.0 */
+       { 0x00, 0x1B, 0x1E }, /* -19.5 */
+       { 0x00, 0x19, 0x9A }, /* -20.0 */
+       { 0x00, 0x18, 0x2B }, /* -20.5 */
+       { 0x00, 0x16, 0xD1 }, /* -21.0 */
+       { 0x00, 0x15, 0x8A }, /* -21.5 */
+       { 0x00, 0x14, 0x56 }, /* -22.0 */
+       { 0x00, 0x13, 0x33 }, /* -22.5 */
+       { 0x00, 0x12, 0x20 }, /* -23.0 */
+       { 0x00, 0x11, 0x1C }, /* -23.5 */
+       { 0x00, 0x10, 0x27 }, /* -24.0 */
+       { 0x00, 0x0F, 0x40 }, /* -24.5 */
+       { 0x00, 0x0E, 0x65 }, /* -25.0 */
+       { 0x00, 0x0D, 0x97 }, /* -25.5 */
+       { 0x00, 0x0C, 0xD5 }, /* -26.0 */
+       { 0x00, 0x0C, 0x1D }, /* -26.5 */
+       { 0x00, 0x0B, 0x6F }, /* -27.0 */
+       { 0x00, 0x0A, 0xCC }, /* -27.5 */
+       { 0x00, 0x0A, 0x31 }, /* -28.0 */
+       { 0x00, 0x09, 0x9F }, /* -28.5 */
+       { 0x00, 0x09, 0x15 }, /* -29.0 */
+       { 0x00, 0x08, 0x93 }, /* -29.5 */
+       { 0x00, 0x08, 0x18 }, /* -30.0 */
+       { 0x00, 0x07, 0xA5 }, /* -30.5 */
+       { 0x00, 0x07, 0x37 }, /* -31.0 */
+       { 0x00, 0x06, 0xD0 }, /* -31.5 */
+       { 0x00, 0x06, 0x6E }, /* -32.0 */
+       { 0x00, 0x06, 0x12 }, /* -32.5 */
+       { 0x00, 0x05, 0xBB }, /* -33.0 */
+       { 0x00, 0x05, 0x69 }, /* -33.5 */
+       { 0x00, 0x05, 0x1C }, /* -34.0 */
+       { 0x00, 0x04, 0xD2 }, /* -34.5 */
+       { 0x00, 0x04, 0x8D }, /* -35.0 */
+       { 0x00, 0x04, 0x4C }, /* -35.5 */
+       { 0x00, 0x04, 0x0F }, /* -36.0 */
+       { 0x00, 0x03, 0xD5 }, /* -36.5 */
+       { 0x00, 0x03, 0x9E }, /* -37.0 */
+       { 0x00, 0x03, 0x6A }, /* -37.5 */
+       { 0x00, 0x03, 0x39 }, /* -38.0 */
+       { 0x00, 0x03, 0x0B }, /* -38.5 */
+       { 0x00, 0x02, 0xDF }, /* -39.0 */
+       { 0x00, 0x02, 0xB6 }, /* -39.5 */
+       { 0x00, 0x02, 0x8F }, /* -40.0 */
+       { 0x00, 0x02, 0x6B }, /* -40.5 */
+       { 0x00, 0x02, 0x48 }, /* -41.0 */
+       { 0x00, 0x02, 0x27 }, /* -41.5 */
+       { 0x00, 0x02, 0x09 }, /* -42.0 */
+       { 0x00, 0x01, 0xEB }, /* -42.5 */
+       { 0x00, 0x01, 0xD0 }, /* -43.0 */
+       { 0x00, 0x01, 0xB6 }, /* -43.5 */
+       { 0x00, 0x01, 0x9E }, /* -44.0 */
+       { 0x00, 0x01, 0x86 }, /* -44.5 */
+       { 0x00, 0x01, 0x71 }, /* -45.0 */
+       { 0x00, 0x01, 0x5C }, /* -45.5 */
+       { 0x00, 0x01, 0x48 }, /* -46.0 */
+       { 0x00, 0x01, 0x36 }, /* -46.5 */
+       { 0x00, 0x01, 0x25 }, /* -47.0 */
+       { 0x00, 0x01, 0x14 }, /* -47.5 */
+       { 0x00, 0x01, 0x05 }, /* -48.0 */
+       { 0x00, 0x00, 0xF6 }, /* -48.5 */
+       { 0x00, 0x00, 0xE9 }, /* -49.0 */
+       { 0x00, 0x00, 0xDC }, /* -49.5 */
+       { 0x00, 0x00, 0xCF }, /* -50.0 */
+       { 0x00, 0x00, 0xC4 }, /* -50.5 */
+       { 0x00, 0x00, 0xB9 }, /* -51.0 */
+       { 0x00, 0x00, 0xAE }, /* -51.5 */
+       { 0x00, 0x00, 0xA5 }, /* -52.0 */
+       { 0x00, 0x00, 0x9B }, /* -52.5 */
+       { 0x00, 0x00, 0x93 }, /* -53.0 */
+       { 0x00, 0x00, 0x8B }, /* -53.5 */
+       { 0x00, 0x00, 0x83 }, /* -54.0 */
+       { 0x00, 0x00, 0x7B }, /* -54.5 */
+       { 0x00, 0x00, 0x75 }, /* -55.0 */
+       { 0x00, 0x00, 0x6E }, /* -55.5 */
+       { 0x00, 0x00, 0x68 }, /* -56.0 */
+       { 0x00, 0x00, 0x62 }, /* -56.5 */
+       { 0x00, 0x00, 0x0 } /* Mute? */
+};
+
 /* TAS3001 registers */
 #define DEQ_MCR                0x01    /* Main Control Register (1byte) */
 #define DEQ_DRC                0x02    /* Dynamic Range Compression (2bytes) */
@@ -321,19 +477,29 @@ void
 tumbler_set_volume(struct tumbler_softc *sc, int left, int right)
 {
        u_char vol[6];
+       int nentries = sizeof(tumbler_volumetab) / sizeof(tumbler_volumetab[0]);
+       int l, r;
 
        sc->sc_vol_l = left;
        sc->sc_vol_r = right;
 
-       left <<= 6;     /* XXX for now */
-       right <<= 6;
+       l = nentries - (left * nentries / 256);
+       r = nentries - (right * nentries / 256);
 
-       vol[0] = left >> 16;
-       vol[1] = left >> 8;
-       vol[2] = left;
-       vol[3] = right >> 16;
-       vol[4] = right >> 8;
-       vol[5] = right;
+       DPRINTF(" left %d vol %d %d, right %d vol %d %d\n",
+               left, l, nentries,
+               right, r, nentries);
+       if (l >= nentries)
+               l = nentries - 1;
+       if (r >= nentries)
+               r = nentries - 1;
+
+       vol[0] = tumbler_volumetab[l].high;
+       vol[1] = tumbler_volumetab[l].mid;
+       vol[2] = tumbler_volumetab[l].low;
+       vol[3] = tumbler_volumetab[r].high;
+       vol[4] = tumbler_volumetab[r].mid;
+       vol[5] = tumbler_volumetab[r].low;
 
        tas3001_write(sc, DEQ_VOLUME, vol);
 }
@@ -367,7 +533,7 @@ tumbler_set_bass(struct tumbler_softc *s
 const struct tas3001_reg tas3001_initdata = {
        { DEQ_MCR_SC_64 | DEQ_MCR_I2S | DEQ_MCR_W_20 },         /* MCR */
        { DEQ_DRC_CR_31, 0xa0 },                                /* DRC */
-       { 0, 0, 0, 0, 0, 0 },                                   /* VOLUME */
+       { 0x00, 0xd7, 0x66, 0x00, 0xd7, 0x66 },                 /* VOLUME */
        { 0x72 },                                               /* TREBLE */
        { 0x3e },                                               /* BASS */
        { 0x10, 0x00, 0x00 },                                   /* MIXER1 */
@@ -485,7 +651,9 @@ tumbler_init(struct tumbler_softc *sc)
        if (tas3001_init(sc))
                return;
 
-       tumbler_set_volume(sc, 80, 80);
+       tumbler_set_volume(sc, 190, 190);
+       tumbler_set_treble(sc, 128); /* 0 dB */
+       tumbler_set_bass(sc, 128); /* 0 dB */
 }
 
 int

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Reply via email to