Re: HCI Set custom bandwidth for AuriStream SCO codec

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

 



On Tuesday 26 November 2019 10:58:38 Pali Rohár wrote:
> On Tuesday 26 November 2019 11:41:50 Luiz Augusto von Dentz wrote:
> > Hi Pali,
> > 
> > On Tue, Nov 26, 2019 at 10:00 AM Pali Rohár <pali.rohar@xxxxxxxxx> wrote:
> > >
> > > On Tuesday 26 November 2019 08:58:44 Marcel Holtmann wrote:
> > > > Hi Pali,
> > > >
> > > > >>>>> I played more with C99 flexible arrays and seems that gcc supports it
> > > > >>>>> without any problems. I'm sending another attempt of API implementation,
> > > > >>>>> now with more fields which are needed for Enhanced Setup Synchronous
> > > > >>>>> Connection command. This command is not supported by kernel yet, but
> > > > >>>>> should be easy to add it. So my ioctl API is prepared for it. Enhanced
> > > > >>>>> Setup Synchronous Connection command would be needed to use hardware
> > > > >>>>> mSBC codec encoder/decoder.
> > > > >>>>>
> > > > >>>>> --
> > > > >>>>> Pali Rohár
> > > > >>>>> pali.rohar@xxxxxxxxx
> > > > >>>>> diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
> > > > >>>>> index fabee6db0abb..29590c6749d5 100644
> > > > >>>>> --- a/include/net/bluetooth/bluetooth.h
> > > > >>>>> +++ b/include/net/bluetooth/bluetooth.h
> > > > >>>>> @@ -116,12 +116,49 @@ struct bt_voice {
> > > > >>>>>         __u16 setting;
> > > > >>>>> };
> > > > >>>>>
> > > > >>>>> -#define BT_VOICE_TRANSPARENT                   0x0003
> > > > >>>>> -#define BT_VOICE_CVSD_16BIT                    0x0060
> > > > >>>>> -
> > > > >>>>> #define BT_SNDMTU               12
> > > > >>>>> #define BT_RCVMTU               13
> > > > >>>>>
> > > > >>>>> +#define BT_VOICE_SETUP         14
> > > > >>>>> +#define BT_VOICE_PKT_TYPE_CAP_SCO      BIT(0)
> > > > >>>>> +#define BT_VOICE_PKT_TYPE_CAP_ESCO     BIT(1)
> > > > >>>>> +struct bt_voice_pkt_type {
> > > > >>>>> +       __u8 capability; /* bitmask of BT_VOICE_PKT_TYPE_CAP_* */
> > > > >>>>> +       __u8 retrans_effort;
> > > > >>>>> +       __u16 pkt_type;
> > > > >>>>> +       __u16 max_latency;
> > > > >>>>> +};
> > > > >>>>> +#define BT_VOICE_SETUP_FEATURE_CONFIG          BIT(0) /* Additional configuration fields after voice_settings are set (including other features) */
> > > > >>>>> +#define BT_VOICE_SETUP_FEATURE_ADD_SCO         BIT(1) /* Can use Add Synchronous Connection */
> > > > >>>>> +#define BT_VOICE_SETUP_FEATURE_SETUP_SCO       BIT(2) /* Can use Setup Synchronous Connection */
> > > > >>>>> +#define BT_VOICE_SETUP_FEATURE_ENH_SETUP_SCO   BIT(3) /* Can use Enhanced Setup Synchronous Connection */
> > > > >>>>> +struct bt_voice_setup {
> > > > >>>>> +       __u16 voice_setting;
> > > > >>>>> +       __u8 features; /* bitmask of BT_VOICE_SETUP_FEATURE_* */
> > > > >>>>> +       __u8 pkt_types_count;
> > > > >>>>> +       __u32 tx_bandwidth;
> > > > >>>>> +       __u32 rx_bandwidth;
> > > > >>>>> +       __u32 input_bandwidth;
> > > > >>>>> +       __u32 output_bandwidth;
> > > > >>>>> +       __u8 tx_coding_format[5];
> > > > >>>>> +       __u8 rx_coding_format[5];
> > > > >>>>> +       __u8 input_coding_format[5];
> > > > >>>>> +       __u8 output_coding_format[5];
> > > > >>>>> +       __u16 tx_codec_frame_size;
> > > > >>>>> +       __u16 rx_codec_frame_size;
> > > > >>>>> +       __u16 input_coded_data_size;
> > > > >>>>> +       __u16 output_coded_data_size;
> > > > >>>>> +       __u8 input_pcm_data_format;
> > > > >>>>> +       __u8 output_pcm_data_format;
> > > > >>>>> +       __u8 input_pcm_msb_position;
> > > > >>>>> +       __u8 output_pcm_msb_position;
> > > > >>>>> +       __u8 input_data_path;
> > > > >>>>> +       __u8 output_data_path;
> > > > >>>>> +       __u8 input_unit_size;
> > > > >>>>> +       __u8 output_unit_size;
> > > > >>>>> +       struct bt_voice_pkt_type pkt_types[];
> > > > >>>>> +};
> > > > >>>>> +
> > > > >>>>
> > > > >>>> lets not mush these together. One of these are air codecs and setup defined by a profile, the other are local codec path defined by the platform.
> > > > >>>
> > > > >>> You are right that air codecs are defined by profile and local codecs by
> > > > >>> platform / bluetooth adapter. But ...
> > > > >>>
> > > > >>>> You will also not have multiple local codec path. That will be one and they will not be negotiated. The eSCO settings however will be negotiated.
> > > > >>>
> > > > >>> Above structure specify exactly one codec setup and then multiple packet
> > > > >>> types. See that flexible array is only for packet types, not for whole
> > > > >>> codec structure.
> > > > >>>
> > > > >>> And all above parameters are required for Enhanced Setup Synchronous
> > > > >>> Connection command. So kernel needs to know what should put into
> > > > >>> Enhanced Setup Synchronous Connection command when creating a new SCO
> > > > >>> connection. So for supporting Enhanced Setup Synchronous Connection
> > > > >>> command userspace needs to pass all above parameters to kernel.
> > > > >>>
> > > > >>> And usage of Enhanced Setup Synchronous Connection is required when we
> > > > >>> want to use in-hardware encoding/decoding of mSBC codec. E.g. new
> > > > >>> Thinkpads already have bluetooth adapter which supports encoding and
> > > > >>> decoding of mSBC codec in hardware.
> > > > >>>
> > > > >>> So above structure as I define is really needed. Do you see it now?
> > > > >>
> > > > >> the information are needed, but not that struct. It makes no sense to hand this problem of configuring the PCM data path correctly to the profile code. So I am not going to do that. The profile itself has no interest in how the platform is built. What you are going to do is configure possible PCM data path options and then the kernel will use that information for Enhanced Sync Setup. However the profile should only provide the over-the-air settings since that is what is going to be negotiated during the profile setup.
> > > > >
> > > > > Userspace needs to know if kernel expects sound data (via write()) in
> > > > > mSBC or in PCM_s16le. Also userspace needs to know if kernel provides
> > > > > (via read()) sound data in mSBC, PCM_s16le or in other format. Otherwise
> > > > > userspace is not possible to send any data to remote headset correctly.
> > > >
> > > > true, but the profile implementation doesn’t care. It is the audio component eg. PA that cares. Only because HCI has a single command for things, doesn’t mean we are stuffing all of the information via a single ioctl and then let userspace deal with the mess. That is not how we designed things.
> > >
> > > Ok, so how would userspace then can set those other informations?
> > 
> > So to jump in the middle of the discussion but what other formats does
> > the userspace would like to use? Afaik we only have PCM_s16le and
> > transparent encoded data support so far.
> 
> Hi Luiz! As I wrote above, e.g. bluetooth adapters in new Thinkpads
> supports in-hardware mSBC encoding/decoding. So you need to say to
> adapter if you want mSBC or PCM_s16le. Not "transparent". But it needs
> to use "Enhanced Setup Synchronous Connection" call not just basic
> "Setup Synchronous Connection". Structure which I defined above is just
> copy of parameters which needs to be passed to "Enhanced Setup
> Synchronous Connection" call.
> 

Hello, can we move forward in this problem? If above my proposed API for
setting codecs settings is not suitable, could you please propose
different which would provide needed functionality?

Because kernel is currently blocking usage of any other codec and
therefore without fixing this issue it is not possible to use any other
codec.

Also kernel is blocking usage of hardware mSBC encoder and decoder which
is part of bluetooth adapters (e.g. in new Thinkpads) so it is still
needed to do whole encoding / decoding in software...

-- 
Pali Rohár
pali.rohar@xxxxxxxxx



[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux