[haiku-bugs] Re: [Haiku] #8476: Spare HDA jacks available - how can we address them?

  • From: "ttcoder" <trac@xxxxxxxxxxxx>
  • Date: Thu, 30 Aug 2012 16:39:37 -0000

#8476: Spare HDA jacks available - how can we address them?
---------------------------------+----------------------------
   Reporter:  dsuden             |      Owner:  korli
       Type:  enhancement        |     Status:  new
   Priority:  normal             |  Milestone:  R1
  Component:  Drivers/Audio/HDA  |    Version:  R1/Development
 Resolution:                     |   Keywords:
 Blocked By:                     |   Blocking:
Has a Patch:  0                  |   Platform:  All
---------------------------------+----------------------------

Comment (by ttcoder):

 Tu cut a long (very very very long :-) story short, it seems we have a
 success as of this afternoon. It ''seems'' (testing by sending builds to
 Dane through email confuses me more than if I was testing locally
 sometimes!) that the necessary ingredient to that recipe were to have
 ''both'' the "TODO" in hda_controller.cpp resolved and also add a new
 verb, #define VID_SET_CONVERTER_CHANNEL_COUNT             0x72d00, to the
 vocabulary of the driver.

 {{{
 /boot/common/cache/tmp/....haiku..../haiku/src/add-
 ons/kernel/drivers/audio/hda> git diff
 diff --git a/src/add-ons/kernel/drivers/audio/hda/driver.cpp b/src/add-
 ons/kernel/drivers/audio/hda/driver.cpp
 index e0d05f8..18982eb 100644
 (..)
 diff --git a/src/add-ons/kernel/drivers/audio/hda/hda_codec_defs.h b/src
 /add-ons/kernel/drivers/audio/hda/hda_codec_defs.h
 index 1c4d021..9148c0e 100644
 --- a/src/add-ons/kernel/drivers/audio/hda/hda_codec_defs.h
 +++ b/src/add-ons/kernel/drivers/audio/hda/hda_codec_defs.h
 @@ -69,6 +69,7 @@ enum pin_dev_type {
  #define VID_SET_CONVERTER_FORMAT                       0x20000
  #define VID_GET_CONVERTER_STREAM_CHANNEL       0xf0600
  #define VID_SET_CONVERTER_STREAM_CHANNEL       0x70600
 +#define VID_SET_CONVERTER_CHANNEL_COUNT                0x72d00//
  #define VID_GET_DIGITAL_CONVERTER_CONTROL      0xf0d00
  #define VID_SET_DIGITAL_CONVERTER_CONTROL1     0x70d00
  #define VID_SET_DIGITAL_CONVERTER_CONTROL2     0x70e00
 diff --git a/src/add-ons/kernel/drivers/audio/hda/hda_controller.cpp b/src
 /add-ons/kernel/drivers/audio/hda/hda_controller.cpp
 index 350e36a..40e6c19 100644
 --- a/src/add-ons/kernel/drivers/audio/hda/hda_controller.cpp
 +++ b/src/add-ons/kernel/drivers/audio/hda/hda_controller.cpp
 @@ -570,10 +570,10 @@ status_t
  hda_stream_setup_buffers(hda_audio_group* audioGroup, hda_stream* stream,
         const char* desc)
  {
 -       uint32 response[2];
 +       uint32 response[3];
         physical_entry pe;
         bdl_entry_t* bufferDescriptors;
 -       corb_t verb[2];
 +       corb_t verb[3];
         uint8* buffer;
         status_t rc;

 @@ -707,6 +707,7 @@ hda_stream_setup_buffers(hda_audio_group* audioGroup,
 hda_stream* stream,
         dprintf("hda: stream: %ld fifo size: %d num_io_widgets: %ld\n",
 stream->id,
                 stream->Read16(HDAC_STREAM_FIFO_SIZE),
 stream->num_io_widgets);
         dprintf("hda: widgets: ");
 +       dprintf("\n");

         hda_codec* codec = audioGroup->codec;
         uint32 channelNum = 0;
 @@ -720,9 +721,19 @@ hda_stream_setup_buffers(hda_audio_group* audioGroup,
 hda_stream* stream,
                         val = 0;
                 verb[1] = MAKE_VERB(codec->addr, stream->io_widgets[i],
                         VID_SET_CONVERTER_STREAM_CHANNEL, val);
 -               hda_send_verbs(codec, verb, response, 2);
 +if(i%2)
 +               verb[2] = MAKE_VERB(codec->addr, stream->io_widgets[i],
 +                       VID_SET_CONVERTER_CHANNEL_COUNT, 3);
 +else
 +               verb[2] = MAKE_VERB(codec->addr, stream->io_widgets[i],
 +                       VID_SET_CONVERTER_CHANNEL_COUNT, 1);
 +               hda_send_verbs(codec, verb, response, 3);
                 //channelNum += 2; // TODO stereo widget ? Every output
 gets the same stream for now
 +if(i>=2)
 +channelNum = 2; // TODO stereo widget ? Every output gets the same stream
 for now
                 dprintf("%ld ", stream->io_widgets[i]);
 +               dprintf("widget #%ld <= channels %ld/%ld belonging to
 stream #%ld (val=0x%lx) v0=%lx v1=%lx v2=%lx\n",
 +                       stream->io_widgets[i], channelNum, channelNum+1,
 stream->id, val, verb[0], verb[1], verb[2]);
         }
         dprintf("\n");

 diff --git a/src/add-ons/kernel/drivers/audio/hda/hda_multi_audio.cpp
 b/src/add-ons/kernel/drivers/audio/hda/hda_multi_audio.cpp
 index 0c50f8b..e1d8cef 100644
 --- a/src/add-ons/kernel/drivers/audio/hda/hda_multi_audio.cpp
 +++ b/src/add-ons/kernel/drivers/audio/hda/hda_multi_audio.cpp
 @@ -16,7 +16,7 @@
  #      undef TRACE
  #endif

 -//#define TRACE_MULTI_AUDIO
 +#define TRACE_MULTI_AUDIO
  #ifdef TRACE_MULTI_AUDIO
  #      define TRACE(a...) dprintf("\33[34mhda:\33[0m " a)
  #else
 @@ -85,6 +85,7 @@ get_description(hda_audio_group* audioGroup,
 multi_description* data)
         int32 outChannels = 0;
         if (audioGroup->playback_stream != NULL)
                 outChannels = 2;
 +outChannels = 4;

         data->output_channel_count = outChannels;
         data->output_bus_channel_count = outChannels;
 @@ -144,6 +145,8 @@ get_enabled_channels(hda_audio_group* audioGroup,
 multi_channel_enable* data)
         B_SET_CHANNEL(data->enable_bits, 1, true);
         B_SET_CHANNEL(data->enable_bits, 2, true);
         B_SET_CHANNEL(data->enable_bits, 3, true);
 +       B_SET_CHANNEL(data->enable_bits, 4, true);
 +       B_SET_CHANNEL(data->enable_bits, 5, true);
         data->lock_source = B_MULTI_LOCK_INTERNAL;

         return B_OK;

 }}}

 I found the new verb in the official HDA doc (thx for the pointer korli!).

 Maybe that new verb could be useful to improve compatibility also (make
 the driver work for more people) since the doc says that verb should be
 sent with the other two; though its main usefulness if for us to have
 multiple streams to multiple jacks of course :-)

 As you'll see above I've leveraged Dane's 4 output jacks to create 4
 different combinations of verb/parameters; I still don't know for sure
 which of the four combinations is the succesful one because the jacks'
 physical ordering seems to differ from their programmatic ordering. Point
 is, Dane now has the main output on 3 jacks, and a nice "Preview" output
 on the remaining 4th jack :-)

 Will confirm and clean this up and later we can see if this can be turned
 into a normal piece of code by opposed to a quick-n-dirty hack.

-- 
Ticket URL: <http://dev.haiku-os.org/ticket/8476#comment:14>
Haiku <http://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: