NetBSD-Bugs archive

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

Re: port-macppc/38952: snapper audio does not work on 14.1" ibook ( Patch for netbsd-4 branch attached).



The following reply was made to PR port-macppc/38952; it has been noted by 
GNATS.

From: "Kailash Sethuraman" <hsaliak%gmail.com@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: port-macppc/38952: snapper audio does not work on 14.1" ibook ( 
Patch for netbsd-4 branch attached).
Date: Mon, 16 Jun 2008 00:57:25 +0800

 The first patch filed along with the PR  is incorrect and will break
 existing behaviour.
 What I think is the correct patch is attached here, for netbsd-4:
 
 Index: dev/snapper.c
 ===================================================================
 RCS file: /cvsroot/src/sys/arch/macppc/dev/snapper.c,v
 retrieving revision 1.13
 diff -b -u -r1.13 snapper.c
 --- dev/snapper.c      24 Sep 2006 03:47:09 -0000      1.13
 +++ dev/snapper.c      14 Jun 2008 04:34:30 -0000
 @@ -88,6 +88,8 @@
        unsigned char   dbdma_cmdspace[sizeof(struct dbdma_command) * 40 + 15];
        struct dbdma_command *sc_odmacmd;
        struct dbdma_command *sc_idmacmd;
 +       u_int sc_baseaddr; /* needed for snapper_gpio */
 +
  };
 
  int snapper_match(struct device *, struct cfdata *, void *);
 @@ -125,6 +127,7 @@
  void snapper_mute_headphone(struct snapper_softc *, int);
  int snapper_cint(void *);
  int tas3004_init(struct snapper_softc *);
 +u_char *snapper_gpio_map(struct snapper_softc *,const char *, int *);
  void snapper_init(struct snapper_softc *, int);
 
  struct cfattach snapper_ca = {
 @@ -548,7 +551,7 @@
        struct confargs *ca;
        unsigned long v;
        int cirq, oirq, iirq, cirq_type, oirq_type, iirq_type;
 -      int soundbus, intr[6];
 +      int soundbus, intr[6], reg[6];
 
        sc = (struct snapper_softc *)self;
        ca = aux;
 @@ -564,16 +567,17 @@
        }
  #endif
 
 -      ca->ca_reg[0] += ca->ca_baseaddr;
 -      ca->ca_reg[2] += ca->ca_baseaddr;
 -      ca->ca_reg[4] += ca->ca_baseaddr;
 -
        sc->sc_node = ca->ca_node;
 -      sc->sc_reg = (void *)ca->ca_reg[0];
 -      sc->sc_odma = (void *)ca->ca_reg[2];
 -      sc->sc_idma = (void *)ca->ca_reg[4];
 -
        soundbus = OF_child(ca->ca_node);
 +      OF_getprop(soundbus, "reg", reg, sizeof reg);
 +      reg[0] += ca->ca_baseaddr;
 +      reg[2] += ca->ca_baseaddr;
 +      reg[4] += ca->ca_baseaddr;
 +      sc->sc_reg = (void *)reg[0];
 +      sc->sc_odma = (void *)reg[2];
 +      sc->sc_idma = (void *)reg[4];
 +      sc->sc_baseaddr = ca->ca_baseaddr; /* needed for snapper_gpio_map */
 +
        OF_getprop(soundbus, "interrupts", intr, sizeof intr);
        cirq = intr[0];
        oirq = intr[2];
 @@ -606,7 +610,8 @@
                        sc->sc_i2c = dv;
        */
        for (dv = alldevs.tqh_first; dv; dv=dv->dv_list.tqe_next)
 -              if (strncmp(dv->dv_xname, "deq", 3) == 0 &&
 +        if (((strncmp(dv->dv_xname, "deq", 3) == 0) ||
 +             (strncmp(dv->dv_xname, "codec", 5) == 0)) &&
                    strncmp(device_parent(dv)->dv_xname, "ki2c", 4) == 0) {
                        deq=(struct deq_softc *)dv;
                        sc->sc_i2c = deq->sc_i2c;
 @@ -1673,6 +1678,35 @@
  #define I2S1EN                0x100000
 
  #define FCR3C_BITMASK "\020\25I2S1EN\24I2S1CLKEN\16I2S0EN\15I2S0CLKEN"
 +  /* snapper_gpio_map tries to obtain and map the gpio registers from
 +     the soundbus */
 +u_char *
 +snapper_gpio_map(struct snapper_softc *sc, const char *name, int *irq)
 +{
 +
 +      u_int32_t reg[2];
 +      u_int32_t intr[2];
 +      int gpio;
 +      int soundbus;
 +
 +
 +      if((soundbus = OF_child(sc->sc_node)) == 0)
 +         return NULL;
 +
 +      if (OF_getprop(soundbus, name, &gpio,
 +            sizeof(gpio)) != sizeof(gpio) ||
 +          OF_getprop(gpio, "reg", &reg[0],
 +          sizeof(reg[0])) != sizeof(reg[0]) ||
 +          OF_getprop(OF_parent(gpio), "reg", &reg[1],
 +          sizeof(reg[1])) != sizeof(reg[1]))
 +              return NULL;
 +
 +      if (irq && OF_getprop(gpio, "interrupts",
 +          intr, sizeof(intr)) == sizeof(intr)) {
 +              *irq = intr[0];
 +      }
 +      return mapiodev(sc->sc_baseaddr + reg[0] + reg[1], 1);
 +}
 
  void
  snapper_init(struct snapper_softc *sc, int node)
 @@ -1690,6 +1724,15 @@
        gpio = getnodebyname(OF_parent(node), "gpio");
        DPRINTF(" /gpio 0x%x\n", gpio);
        gpio = OF_child(gpio);
 +      /* Check if we can use the soundbus's 2nd reg for our purpose */
 +      amp_mute = snapper_gpio_map(sc, "platform-amp-mute", NULL);
 +      headphone_mute = snapper_gpio_map(sc, "platform-headphone-mute", NULL);
 +      headphone_detect = snapper_gpio_map(sc, "platform-headphone-detect",
 +          &headphone_detect_intr);
 +      /*      lineout_mute = snapper_gpio_map(sc, "platform-lineout-mute", 
NULL);
 +      lineout_detect = snapper_gpio_map(sc, "platform-lineout-detect",
 +      &lineout_detect_intr);  */
 +      audio_hw_reset = snapper_gpio_map(sc, "platform-hw-reset", NULL);
        while (gpio) {
                char name[64], audio_gpio[64];
                int intr[2];
 @@ -1704,13 +1747,13 @@
                DPRINTF(" 0x%x %s %s\n", gpio, name, audio_gpio);
 
                /* gpio5 */
 -              if (strcmp(audio_gpio, "headphone-mute") == 0)
 +              if (headphone_mute == NULL && strcmp(audio_gpio, 
"headphone-mute") == 0)
                        headphone_mute = addr;
                /* gpio6 */
 -              if (strcmp(audio_gpio, "amp-mute") == 0)
 +              if (amp_mute == NULL && strcmp(audio_gpio, "amp-mute") == 0)
                        amp_mute = addr;
                /* extint-gpio15 */
 -              if (strcmp(audio_gpio, "headphone-detect") == 0) {
 +              if (headphone_detect == NULL && strcmp(audio_gpio,
 "headphone-detect") == 0) {
                        headphone_detect = addr;
                        OF_getprop(gpio, "audio-gpio-active-state",
                            &headphone_detect_active, 4);
 @@ -1719,7 +1762,7 @@
                        headphone_detect_intrtype = intr[1];
                }
                /* gpio11 (keywest-11) */
 -              if (strcmp(audio_gpio, "audio-hw-reset") == 0)
 +              if (audio_hw_reset == NULL && strcmp(audio_gpio, 
"audio-hw-reset") == 0)
                        audio_hw_reset = addr;
                gpio = OF_peer(gpio);
        }
 Index: dev/deq.c
 ===================================================================
 RCS file: /cvsroot/src/sys/arch/macppc/dev/deq.c,v
 retrieving revision 1.2
 diff -b -u -r1.2 deq.c
 --- dev/deq.c  11 Dec 2005 12:18:03 -0000      1.2
 +++ dev/deq.c  14 Jun 2008 04:34:30 -0000
 @@ -64,11 +64,11 @@
        struct ki2c_confargs *ka = aux;
        char compat[32];
        
 -      if (strcmp(ka->ka_name, "deq") != 0)
 +      if ((strcmp(ka->ka_name, "deq") != 0) && (strcmp(ka->ka_name,"codec")!= 
0))
                return 0;
 
        memset(compat, 0, sizeof(compat));
 -      if(OF_getprop(ka->ka_node, "i2c-address", compat, sizeof(compat)))
 +      if(OF_getprop(ka->ka_node, "i2c-address", compat,sizeof(compat)))
                return 1;
        return 0;
  }
 


Home | Main Index | Thread Index | Old Index