Re: [PATCH] a2dp-codecs & avinfo: Simplify defintions and parsing of aptX family

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

 



Hi Pali,
On Sat, Jan 26, 2019 at 12:48 PM Pali Rohár <pali.rohar@xxxxxxxxx> wrote:
>
> Reuse whole a2dp_aptx_t structure and defines as they are same for aptX Low
> Latency and aptX HD.
> ---
>  profiles/audio/a2dp-codecs.h | 46 ++++++--------------------------------
>  tools/avinfo.c               | 53 +++++++++++++-------------------------------
>  2 files changed, 22 insertions(+), 77 deletions(-)
>
> diff --git a/profiles/audio/a2dp-codecs.h b/profiles/audio/a2dp-codecs.h
> index f31f3a311..4789e27ed 100644
> --- a/profiles/audio/a2dp-codecs.h
> +++ b/profiles/audio/a2dp-codecs.h
> @@ -213,14 +213,6 @@
>  #define APTX_LL_VENDOR_ID              0x0000000a
>  #define APTX_LL_CODEC_ID               0x0002
>
> -#define APTX_LL_CHANNEL_MODE_MONO      0x01
> -#define APTX_LL_CHANNEL_MODE_STEREO    0x02
> -
> -#define APTX_LL_SAMPLING_FREQ_16000    0x08
> -#define APTX_LL_SAMPLING_FREQ_32000    0x04
> -#define APTX_LL_SAMPLING_FREQ_44100    0x02
> -#define APTX_LL_SAMPLING_FREQ_48000    0x01
> -
>  /* Default parameters for aptX Low Latency encoder */
>
>  /* Target codec buffer level = 180 */
> @@ -244,14 +236,6 @@
>  #define APTX_HD_VENDOR_ID              0x000000D7
>  #define APTX_HD_CODEC_ID               0x0024
>
> -#define APTX_HD_CHANNEL_MODE_MONO      0x1
> -#define APTX_HD_CHANNEL_MODE_STEREO    0x2
> -
> -#define APTX_HD_SAMPLING_FREQ_16000    0x8
> -#define APTX_HD_SAMPLING_FREQ_32000    0x4
> -#define APTX_HD_SAMPLING_FREQ_44100    0x2
> -#define APTX_HD_SAMPLING_FREQ_48000    0x1
> -
>  #define LDAC_VENDOR_ID                 0x0000012d
>  #define LDAC_CODEC_ID                  0x00aa
>
> @@ -360,25 +344,13 @@ typedef struct {
>  } __attribute__ ((packed)) a2dp_faststream_t;
>
>  typedef struct {
> -       a2dp_vendor_codec_t info;
> -       uint8_t channel_mode:4;
> -       uint8_t frequency:4;
> +       a2dp_aptx_t aptx;
>         uint8_t bidirect_link:1;
>         uint8_t has_new_caps:1;
>         uint8_t reserved:6;
>         a2dp_aptx_ll_new_caps_t new_caps[0];
>  } __attribute__ ((packed)) a2dp_aptx_ll_t;
>
> -typedef struct {
> -       a2dp_vendor_codec_t info;
> -       uint8_t channel_mode:4;
> -       uint8_t frequency:4;
> -       uint8_t reserved0;
> -       uint8_t reserved1;
> -       uint8_t reserved2;
> -       uint8_t reserved3;
> -} __attribute__ ((packed)) a2dp_aptx_hd_t;
> -
>  #elif defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && \
>         __BYTE_ORDER == __BIG_ENDIAN
>
> @@ -430,25 +402,21 @@ typedef struct {
>  } __attribute__ ((packed)) a2dp_faststream_t;
>
>  typedef struct {
> -       a2dp_vendor_codec_t info;
> -       uint8_t frequency:4;
> -       uint8_t channel_mode:4;
> +       a2dp_aptx_t aptx;
>         uint8_t reserved:6;
>         uint8_t has_new_caps:1;
>         uint8_t bidirect_link:1;
>         a2dp_aptx_ll_new_caps_t new_caps[0];
>  } __attribute__ ((packed)) a2dp_aptx_ll_t;
>
> +#else
> +#error "Unknown byte order"
> +#endif
> +
>  typedef struct {
> -       a2dp_vendor_codec_t info;
> -       uint8_t frequency:4;
> -       uint8_t channel_mode:4;
> +       a2dp_aptx_t aptx;
>         uint8_t reserved0;
>         uint8_t reserved1;
>         uint8_t reserved2;
>         uint8_t reserved3;
>  } __attribute__ ((packed)) a2dp_aptx_hd_t;
> -
> -#else
> -#error "Unknown byte order"
> -#endif
> diff --git a/tools/avinfo.c b/tools/avinfo.c
> index 42f539f43..852d7b67e 100644
> --- a/tools/avinfo.c
> +++ b/tools/avinfo.c
> @@ -168,15 +168,8 @@ struct avdtp_content_protection_capability {
>         uint8_t data[0];
>  } __attribute__ ((packed));
>
> -static void print_aptx(a2dp_aptx_t *aptx, uint8_t size)
> +static void print_aptx_common(a2dp_aptx_t *aptx)
>  {
> -       printf("\t\tVendor Specific Value (aptX)");
> -
> -       if (size < sizeof(*aptx)) {
> -               printf(" (broken)\n");
> -               return;
> -       }
> -
>         printf("\n\t\t\tFrequencies: ");
>         if (aptx->frequency & APTX_SAMPLING_FREQ_16000)
>                 printf("16kHz ");
> @@ -192,6 +185,18 @@ static void print_aptx(a2dp_aptx_t *aptx, uint8_t size)
>                 printf("Mono ");
>         if (aptx->channel_mode & APTX_CHANNEL_MODE_STEREO)
>                 printf("Stereo ");
> +}
> +
> +static void print_aptx(a2dp_aptx_t *aptx, uint8_t size)
> +{
> +       printf("\t\tVendor Specific Value (aptX)");
> +
> +       if (size < sizeof(*aptx)) {
> +               printf(" (broken)\n");
> +               return;
> +       }
> +
> +       print_aptx_common(aptx);
>
>         printf("\n");
>  }
> @@ -242,21 +247,7 @@ static void print_aptx_ll(a2dp_aptx_ll_t *aptx_ll, uint8_t size)
>                 return;
>         }
>
> -       printf("\n\t\t\tFrequencies: ");
> -       if (aptx_ll->frequency & APTX_LL_SAMPLING_FREQ_16000)
> -               printf("16kHz ");
> -       if (aptx_ll->frequency & APTX_LL_SAMPLING_FREQ_32000)
> -               printf("32kHz ");
> -       if (aptx_ll->frequency & APTX_LL_SAMPLING_FREQ_44100)
> -               printf("44.1kHz ");
> -       if (aptx_ll->frequency & APTX_LL_SAMPLING_FREQ_48000)
> -               printf("48kHz ");
> -
> -       printf("\n\t\t\tChannel modes: ");
> -       if (aptx_ll->channel_mode & APTX_LL_CHANNEL_MODE_MONO)
> -               printf("Mono ");
> -       if (aptx_ll->channel_mode & APTX_LL_CHANNEL_MODE_STEREO)
> -               printf("Stereo ");
> +       print_aptx_common(&aptx_ll->aptx);
>
>         printf("\n\t\tBidirectional link: %s",
>                         aptx_ll->bidirect_link ? "Yes" : "No");
> @@ -292,21 +283,7 @@ static void print_aptx_hd(a2dp_aptx_hd_t *aptx_hd, uint8_t size)
>                 return;
>         }
>
> -       printf("\n\t\t\tFrequencies: ");
> -       if (aptx_hd->frequency & APTX_HD_SAMPLING_FREQ_16000)
> -               printf("16kHz ");
> -       if (aptx_hd->frequency & APTX_HD_SAMPLING_FREQ_32000)
> -               printf("32kHz ");
> -       if (aptx_hd->frequency & APTX_HD_SAMPLING_FREQ_44100)
> -               printf("44.1kHz ");
> -       if (aptx_hd->frequency & APTX_HD_SAMPLING_FREQ_48000)
> -               printf("48kHz ");
> -
> -       printf("\n\t\t\tChannel modes: ");
> -       if (aptx_hd->channel_mode & APTX_HD_CHANNEL_MODE_MONO)
> -               printf("Mono ");
> -       if (aptx_hd->channel_mode & APTX_HD_CHANNEL_MODE_STEREO)
> -               printf("Stereo ");
> +       print_aptx_common(&aptx_hd->aptx);
>
>         printf("\n");
>  }
> --
> 2.11.0

Applied, thanks.

-- 
Luiz Augusto von Dentz




[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