Notice: We have migrated to GitLab launching 2024-05-01 see here: https://gitlab.rtems.org/

Ticket #2045: milkymist-audio-add-support-mic-boost.patch

File milkymist-audio-add-support-mic-boost.patch, 1.7 KB (added by Sebastien Bourdeauducq, on 03/29/12 at 09:12:57)

patch

  • c/src/lib/libbsp/lm32/shared/milkymist_ac97/ac97.c

    old new  
    316316  unsigned int chan, int mono)
    317317{
    318318  unsigned int *val = (unsigned int *)buf;
     319  int mic_boost;
    319320  int codec;
    320321  int left, right;
    321322
     
    328329    return RTEMS_SUCCESSFUL;
    329330  }
    330331  if (mono) {
    331     right = left = 100-(((codec & 0x1f) + 1)*100)/32;
     332    left = 100-(((codec & 0x1f) + 1)*100)/32;
     333    mic_boost = (codec & (1 << 6)) >> 6;
     334    *val = left | mic_boost << 8;
    332335  } else {
    333336    right = 100-(((codec & 0x1f) + 1)*100)/32;
    334337    left = 100-((((codec & 0x1f00) >> 8) + 1)*100)/32;
     338    *val = left | (right << 8);
    335339  }
    336   *val = left | (right << 8);
    337340  return RTEMS_SUCCESSFUL;
    338341}
    339342
     
    341344  unsigned int chan, int mono)
    342345{
    343346  unsigned int *val = (unsigned int *)buf;
     347  int mic_boost;
    344348  int left, right;
    345349  int codec;
    346350  rtems_status_code sc;
    347351
    348352  left = *val & 0xff;
    349353  left = (left*32)/100 - 1;
    350   if(left < 0)
     354  if (left < 0)
    351355    left = 0;
    352356
    353   if (mono)
     357  if (mono) {
     358    mic_boost = *val >> 8;
    354359    right = 31;
    355   else {
     360  } else {
    356361    right = (*val >> 8) & 0xff;
    357362    right = (right*32)/100 - 1;
    358     if(right < 0)
     363    if (right < 0)
    359364      right = 0;
    360365  }
    361366
     
    365370  else
    366371    codec = (31-left) | ((31-right) << 8);
    367372
     373  if (mono) {
     374    if (mic_boost)
     375      codec |= (1 << 6);
     376    else
     377      codec &= ~(1 << 6);
     378  }
     379
    368380  if (!write_cr(chan, codec))
    369381    sc = RTEMS_UNSATISFIED;
    370382  else