Print this page
10621 audiohd cstyle cleanup

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/audio/drv/audiohd/audiohd.c
          +++ new/usr/src/uts/common/io/audio/drv/audiohd/audiohd.c
↓ open down ↓ 1277 lines elided ↑ open up ↑
1278 1278                  }
1279 1279          }
1280 1280  
1281 1281          return (DDI_SUCCESS);
1282 1282  }
1283 1283  
1284 1284  static void
1285 1285  audiohd_set_pin_monitor_gain(hda_codec_t *codec, audiohd_state_t *statep,
1286 1286      uint_t caddr, audiohd_pin_t *pin, uint64_t gain)
1287 1287  {
1288      -        int                     i, k;
     1288 +        int                     i, k;
1289 1289          uint_t                  ltmp, rtmp;
1290 1290          audiohd_widget_t        *widget;
1291 1291          uint8_t         l, r;
1292 1292  
1293 1293          l = (gain & 0xff00) >> 8;
1294 1294          r = (gain & 0xff);
1295 1295  
1296 1296          for (k = 0; k < pin->num; k++) {
1297 1297                  ltmp = l * pin->mg_gain[k] / 100;
1298 1298                  rtmp = r * pin->mg_gain[k] / 100;
↓ open down ↓ 728 lines elided ↑ open up ↑
2027 2027  
2028 2028          mutex_enter(&statep->hda_mutex);
2029 2029          (void) audioha_codec_verb_get(statep, caddr, wid,
2030 2030              AUDIOHDC_VERB_SET_BEEP_GEN, AUDIOHDC_MUTE_BEEP_GEN);
2031 2031          mutex_exit(&statep->hda_mutex);
2032 2032  }
2033 2033  
2034 2034  static void
2035 2035  audiohd_beep_freq(void *arg, int freq)
2036 2036  {
2037      -        hda_codec_t     *codec = ((audiohd_widget_t *)arg)->codec;
     2037 +        hda_codec_t     *codec = ((audiohd_widget_t *)arg)->codec;
2038 2038          audiohd_state_t *statep = codec->statep;
2039 2039          uint32_t        vid = codec->vid >> 16;
2040 2040          int             divider;
2041 2041  
2042 2042          _NOTE(ARGUNUSED(arg));
2043 2043          if (freq == 0) {
2044 2044                  divider = 0;
2045 2045          } else {
2046 2046                  if (freq > AUDIOHDC_MAX_BEEP_GEN)
2047 2047                          freq = AUDIOHDC_MAX_BEEP_GEN;
↓ open down ↓ 1245 lines elided ↑ open up ↑
3293 3293   * Description:
3294 3294   *      Build the output path in the codec for every pin.
3295 3295   *      First we try to search output path with mixer widget exclusively
3296 3296   *      Then we try to search shared output path with mixer widget.
3297 3297   *      Then we try to search output path without mixer widget exclusively.
3298 3298   *      At last we try to search shared ouput path for the remained pins
3299 3299   */
3300 3300  static void
3301 3301  audiohd_build_output_path(hda_codec_t *codec)
3302 3302  {
3303      -        int                     mnum = 0;
     3303 +        int                     mnum = 0;
3304 3304          uint8_t                 mixer_allow = 1;
3305 3305  
3306 3306          /*
3307 3307           * Work around for laptops which have IDT or AD audio chipset, such as
3308 3308           * HP mini 1000 laptop, Dell Lattitude 6400, Lenovo T60, Lenove R61e.
3309 3309           * We don't allow mixer widget on such path, which leads to speaker
3310 3310           * loud hiss noise.
3311 3311           */
3312 3312          if (codec->codec_info->flags & NO_MIXER)
3313 3313                  mixer_allow = 0;
↓ open down ↓ 279 lines elided ↑ open up ↑
3593 3593                                  widget = codec->widget[wid];
3594 3594                          }
3595 3595                  }
3596 3596          }
3597 3597  }       /* audiohd_finish_output_path() */
3598 3598  
3599 3599  /*
3600 3600   * audiohd_find_input_pins()
3601 3601   *
3602 3602   * Description:
3603      - *      Here we consider a mixer/selector with multi-input as a real sum
3604      - *      widget. Only the first real mixer/selector widget is permitted in
3605      - *      an input path(recording path). If there are more mixers/selectors
3606      - *      execept the first one, only the first input/connection of those
3607      - *      widgets will be used by our driver, that means, we ignore other
3608      - *      inputs of those mixers/selectors.
     3603 + *      Here we consider a mixer/selector with multi-input as a real sum
     3604 + *      widget. Only the first real mixer/selector widget is permitted in
     3605 + *      an input path(recording path). If there are more mixers/selectors
     3606 + *      execept the first one, only the first input/connection of those
     3607 + *      widgets will be used by our driver, that means, we ignore other
     3608 + *      inputs of those mixers/selectors.
3609 3609   */
3610 3610  static int
3611 3611  audiohd_find_input_pins(hda_codec_t *codec, wid_t wid, int allowmixer,
3612 3612      int depth, audiohd_path_t *path)
3613 3613  {
3614 3614          audiohd_widget_t        *widget = codec->widget[wid];
3615 3615          audiohd_pin_t           *pin;
3616 3616          audiohd_state_t         *statep = codec->statep;
3617 3617          uint_t                  caddr = codec->index;
3618 3618          int                     retval = -1;
↓ open down ↓ 481 lines elided ↑ open up ↑
4100 4100   *      Find input pin for monitor path.
4101 4101   *
4102 4102   * Arguments:
4103 4103   *      hda_codec_t             *codec          where the monitor path exists
4104 4104   *      wid_t                   id              no. of widget being searched
4105 4105   *      int                     mixer           share or not
4106 4106   */
4107 4107  static int
4108 4108  audiohd_find_inpin_for_monitor(hda_codec_t *codec, wid_t id, int mixer)
4109 4109  {
4110      -        wid_t                   wid;
     4110 +        wid_t                   wid;
4111 4111          audiohd_widget_t        *widget, *w;
4112 4112          audiohd_pin_t           *pin;
4113      -        int                     i, find = 0;
     4113 +        int                     i, find = 0;
4114 4114  
4115 4115          wid = id;
4116 4116          widget = codec->widget[wid];
4117 4117          if (widget == NULL)
4118 4118                  return (uint32_t)(DDI_FAILURE);
4119 4119  
4120 4120          if (widget->type == WTYPE_PIN) {
4121 4121                  pin = (audiohd_pin_t *)widget->priv;
4122 4122                  if (pin->no_phys_conn)
4123 4123                          return (uint32_t)(DDI_FAILURE);
↓ open down ↓ 57 lines elided ↑ open up ↑
4181 4181                  return (uint32_t)(DDI_FAILURE);
4182 4182          }
4183 4183          else
4184 4184                  return (DDI_SUCCESS);
4185 4185  }       /* audiohd_find_inpin_for_monitor */
4186 4186  
4187 4187  /*
4188 4188   * audiohd_build_monitor_path()
4189 4189   *
4190 4190   * Description:
4191      - *      The functionality of mixer is to mix inputs, such as CD-IN, MIC,
4192      - *      Line-in, etc, with DAC outputs, so as to minitor what is being
4193      - *      recorded and implement "What you hear is what you get". However,
4194      - *      this functionality are really hardware-dependent: the inputs
4195      - *      must be directed to MIXER if they can be directed to ADC as
4196      - *      recording sources.
     4191 + *      The functionality of mixer is to mix inputs, such as CD-IN, MIC,
     4192 + *      Line-in, etc, with DAC outputs, so as to minitor what is being
     4193 + *      recorded and implement "What you hear is what you get". However,
     4194 + *      this functionality are really hardware-dependent: the inputs
     4195 + *      must be directed to MIXER if they can be directed to ADC as
     4196 + *      recording sources.
4197 4197   */
4198 4198  static void
4199 4199  audiohd_build_monitor_path(hda_codec_t *codec)
4200 4200  {
4201 4201          audiohd_path_t          *path;
4202 4202          audiohd_widget_t        *widget, *w;
4203 4203          audiohd_state_t         *statep = codec->statep;
4204 4204          wid_t                   wid, next;
4205 4205          int                     i, j, k, l, find;
4206 4206          int                     mixernum = 0;
↓ open down ↓ 95 lines elided ↑ open up ↑
4302 4302  /*
4303 4303   * audiohd_do_finish_monitor_path
4304 4304   *
4305 4305   * Description:
4306 4306   *      Enable the widgets on the monitor path
4307 4307   */
4308 4308  static void
4309 4309  audiohd_do_finish_monitor_path(hda_codec_t *codec, audiohd_widget_t *wgt)
4310 4310  {
4311 4311          uint_t                  caddr = codec->index;
4312      -        audiohd_widget_t        *widget = wgt;
     4312 +        audiohd_widget_t        *widget = wgt;
4313 4313          audiohd_widget_t        *w;
4314 4314          audiohd_state_t         *statep = codec->statep;
4315 4315          wid_t                   wid;
4316 4316          int                     i;
4317 4317          int                     share = 0;
4318 4318  
4319 4319          if (!widget || widget->finish)
4320 4320                  return;
4321 4321          if (widget->path_flags & AUDIOHD_PATH_ADC)
4322 4322                  share = 1;
↓ open down ↓ 33 lines elided ↑ open up ↑
4356 4356   * Description:
4357 4357   *      Enable the monitor path for every ostream path
4358 4358   */
4359 4359  static void
4360 4360  audiohd_finish_monitor_path(hda_codec_t *codec)
4361 4361  {
4362 4362          audiohd_path_t          *path;
4363 4363          audiohd_widget_t        *widget;
4364 4364          audiohd_state_t         *statep = codec->statep;
4365 4365          wid_t                   wid;
4366      -        int                     i, j, k;
     4366 +        int                     i, j, k;
4367 4367  
4368 4368          for (i = 0; i < statep->pathnum; i++) {
4369 4369                  path = statep->path[i];
4370 4370                  if (!path || path->codec != codec || path->path_type != PLAY)
4371 4371                          continue;
4372 4372                  for (j = 0; j < path->pin_nums; j++) {
4373 4373                          for (k = 0; k < path->maxmixer[j]; k++) {
4374 4374                                  wid = path->mon_wid[j][k];
4375 4375                                  if (wid == 0) {
4376 4376                                          continue;
↓ open down ↓ 102 lines elided ↑ open up ↑
4479 4479   *      int             depth           the depth of search
4480 4480   *
4481 4481   * Return:
4482 4482   *      1) wid of Beep widget;
4483 4483   *      2) 0 if no path
4484 4484   */
4485 4485  static wid_t
4486 4486  audiohd_find_beep(hda_codec_t *codec, wid_t wid, int depth)
4487 4487  {
4488 4488          audiohd_widget_t        *widget = codec->widget[wid];
4489      -        wid_t                   wbeep = (uint32_t)(DDI_FAILURE);
4490      -        wid_t                   retval;
     4489 +        wid_t                   wbeep = (uint32_t)(DDI_FAILURE);
     4490 +        wid_t                   retval;
4491 4491  
4492 4492          if (depth > AUDIOHD_MAX_DEPTH)
4493 4493                  return (uint32_t)(DDI_FAILURE);
4494 4494  
4495 4495          if (widget == NULL)
4496 4496                  return (uint32_t)(DDI_FAILURE);
4497 4497  
4498 4498          switch (widget->type) {
4499 4499          case WTYPE_BEEP:
4500 4500                  widget->path_flags |= AUDIOHD_PATH_BEEP;
↓ open down ↓ 700 lines elided ↑ open up ↑
5201 5201                          ddi_dma_free_handle(&port->bdl_dmah);
5202 5202                  }
5203 5203  
5204 5204                  kmem_free(port, sizeof (audiohd_port_t));
5205 5205          }
5206 5206  }
5207 5207  
5208 5208  /*
5209 5209   * audiohd_change_widget_power_state(audiohd_state_t *statep, int state)
5210 5210   * Description:
5211      - *      This routine is used to change the widget power betwen D0 and D2.
5212      - *      D0 is fully on; D2 allows the lowest possible power consuming state
5213      - *      from which it can return to the fully on state: D0.
     5211 + *      This routine is used to change the widget power betwen D0 and D2.
     5212 + *      D0 is fully on; D2 allows the lowest possible power consuming state
     5213 + *      from which it can return to the fully on state: D0.
5214 5214   */
5215 5215  static void
5216 5216  audiohd_change_widget_power_state(audiohd_state_t *statep, int state)
5217 5217  {
5218 5218          int                     i;
5219 5219          wid_t                   wid;
5220 5220          hda_codec_t             *codec;
5221 5221          audiohd_widget_t        *widget;
5222 5222  
5223 5223          for (i = 0; i < AUDIOHD_CODEC_MAX; i++) {
↓ open down ↓ 9 lines elided ↑ open up ↑
5233 5233                                      codec->index, wid,
5234 5234                                      AUDIOHDC_VERB_SET_POWER_STATE,
5235 5235                                      state);
5236 5236                          }
5237 5237                  }
5238 5238          }
5239 5239  }
5240 5240  /*
5241 5241   * audiohd_restore_path()
5242 5242   * Description:
5243      - *      This routine is used to restore the path on the codec.
     5243 + *      This routine is used to restore the path on the codec.
5244 5244   */
5245 5245  static void
5246 5246  audiohd_restore_path(audiohd_state_t *statep)
5247 5247  {
5248 5248          int                     i;
5249 5249          hda_codec_t             *codec;
5250 5250  
5251 5251          for (i = 0; i < AUDIOHD_CODEC_MAX; i++) {
5252 5252                  codec = statep->codec[i];
5253 5253                  if (codec == NULL)
↓ open down ↓ 1 lines elided ↑ open up ↑
5255 5255                  audiohd_finish_output_path(statep->codec[i]);
5256 5256                  audiohd_finish_input_path(statep->codec[i]);
5257 5257                  audiohd_finish_monitor_path(statep->codec[i]);
5258 5258                  audiohd_finish_beep_path(statep->codec[i]);
5259 5259          }
5260 5260  }
5261 5261  
5262 5262  /*
5263 5263   * audiohd_reset_pins_ur_cap()
5264 5264   * Description:
5265      - *      Enable the unsolicited response of the pins which have the unsolicited
5266      - *      response capability
     5265 + *      Enable the unsolicited response of the pins which have the unsolicited
     5266 + *      response capability
5267 5267   */
5268 5268  static void
5269 5269  audiohd_reset_pins_ur_cap(audiohd_state_t *statep)
5270 5270  {
5271 5271          hda_codec_t             *codec;
5272 5272          audiohd_pin_t           *pin;
5273 5273          audiohd_widget_t        *widget;
5274 5274          uint32_t                urctrl;
5275 5275          int                     i;
5276 5276  
↓ open down ↓ 196 lines elided ↑ open up ↑
5473 5473  /*
5474 5474   * audiohd_select_mic()
5475 5475   *
5476 5476   * Description:
5477 5477   *      This function is used for the recording path which has a selector
5478 5478   *      as the sumwidget. We select the external MIC if it is plugged into the
5479 5479   *      MIC jack, otherwise the internal integrated MIC is selected.
5480 5480   */
5481 5481  static void
5482 5482  audiohd_select_mic(audiohd_state_t *statep, uint8_t index,
5483      -uint8_t id, int select)
     5483 +    uint8_t id, int select)
5484 5484  {
5485 5485          hda_codec_t             *codec;
5486 5486          audiohd_path_t          *path;
5487 5487          audiohd_widget_t        *widget, *sumwgt = NULL;
5488 5488          audiohd_pin_t           *pin;
5489 5489          int                     i, j;
5490 5490          wid_t                   wid;
5491 5491  
5492 5492          codec = statep->codec[index];
5493 5493          if (codec == NULL)
↓ open down ↓ 122 lines elided ↑ open up ↑
5616 5616                                  }
5617 5617                          }
5618 5618                  }
5619 5619          }
5620 5620  }
5621 5621  /*
5622 5622   * audiohd_pin_sense()
5623 5623   *
5624 5624   * Description
5625 5625   *
5626      - *      When the earphone is plugged into the jack associtated with the pin
5627      - *      complex, we disable the built in speaker. When the earphone is plugged
5628      - *      out of the jack, we enable the built in speaker.
     5626 + *      When the earphone is plugged into the jack associtated with the pin
     5627 + *      complex, we disable the built in speaker. When the earphone is plugged
     5628 + *      out of the jack, we enable the built in speaker.
5629 5629   */
5630 5630  static void
5631 5631  audiohd_pin_sense(audiohd_state_t *statep, uint32_t resp, uint32_t respex)
5632 5632  {
5633 5633          uint8_t                 index;
5634 5634          uint8_t                 id;
5635 5635          uint32_t                rs;
5636 5636          audiohd_widget_t        *widget;
5637 5637          audiohd_pin_t           *pin;
5638 5638          hda_codec_t             *codec;
↓ open down ↓ 269 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX