Linux bluetooth development
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali.rohar@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH v2 09/10] a2dp-codecs: Add macros and structures for new codecs
Date: Sun, 23 Dec 2018 11:40:20 +0100	[thread overview]
Message-ID: <20181223104021.18620-10-pali.rohar@gmail.com> (raw)
In-Reply-To: <20181223104021.18620-1-pali.rohar@gmail.com>

Add additional codecs: FastStream, aptX Low Latency and aptX HD codecs.
---
 profiles/audio/a2dp-codecs.h | 120 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 120 insertions(+)

diff --git a/profiles/audio/a2dp-codecs.h b/profiles/audio/a2dp-codecs.h
index 6f667d3aa..0bdd29110 100644
--- a/profiles/audio/a2dp-codecs.h
+++ b/profiles/audio/a2dp-codecs.h
@@ -4,6 +4,7 @@
  *
  *  Copyright (C) 2006-2010  Nokia Corporation
  *  Copyright (C) 2004-2010  Marcel Holtmann <marcel@holtmann.org>
+ *  Copyright (C) 2018       Pali Rohár <pali.rohar@gmail.com>
  *
  *
  *  This library is free software; you can redistribute it and/or
@@ -197,6 +198,59 @@
 #define APTX_SAMPLING_FREQ_44100	0x02
 #define APTX_SAMPLING_FREQ_48000	0x01
 
+#define FASTSTREAM_VENDOR_ID		0x0000000a
+#define FASTSTREAM_CODEC_ID		0x0001
+
+#define FASTSTREAM_DIRECTION_SINK	0x1
+#define FASTSTREAM_DIRECTION_SOURCE	0x2
+
+#define FASTSTREAM_SINK_SAMPLING_FREQ_44100	0x2
+#define FASTSTREAM_SINK_SAMPLING_FREQ_48000	0x1
+
+#define FASTSTREAM_SOURCE_SAMPLING_FREQ_16000	0x2
+
+#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 */
+#define APTX_LL_TARGET_LEVEL2	0xb4
+#define APTX_LL_TARGET_LEVEL1	0x00
+
+/* Initial codec buffer level = 360 */
+#define APTX_LL_INITIAL_LEVEL2	0x68
+#define APTX_LL_INITIAL_LEVEL1	0x01
+
+/* SRA max rate 0.005 * 10000 = 50 */
+#define APTX_LL_SRA_MAX_RATE		0x32
+
+/* SRA averaging time = 1s */
+#define APTX_LL_SRA_AVG_TIME		0x01
+
+/* Good working codec buffer level = 180 */
+#define APTX_LL_GOOD_WORKING_LEVEL2	0xB4
+#define APTX_LL_GOOD_WORKING_LEVEL1	0x00
+
+#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
 
@@ -237,6 +291,18 @@ typedef struct {
 	})
 
 typedef struct {
+	uint8_t reserved;
+	uint8_t target_level2;
+	uint8_t target_level1;
+	uint8_t initial_level2;
+	uint8_t initial_level1;
+	uint8_t sra_max_rate;
+	uint8_t sra_avg_time;
+	uint8_t good_working_level2;
+	uint8_t good_working_level1;
+} __attribute__ ((packed)) a2dp_aptx_ll_new_caps_t;
+
+typedef struct {
 	a2dp_vendor_codec_t info;
 	uint8_t frequency;
 	uint8_t channel_mode;
@@ -285,6 +351,33 @@ typedef struct {
 	uint8_t frequency:4;
 } __attribute__ ((packed)) a2dp_aptx_t;
 
+typedef struct {
+	a2dp_vendor_codec_t info;
+	uint8_t direction;
+	uint8_t sink_frequency:4;
+	uint8_t source_frequency:4;
+} __attribute__ ((packed)) a2dp_faststream_t;
+
+typedef struct {
+	a2dp_vendor_codec_t info;
+	uint8_t channel_mode:4;
+	uint8_t frequency:4;
+	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
 
@@ -328,6 +421,33 @@ typedef struct {
 	uint8_t channel_mode:4;
 } __attribute__ ((packed)) a2dp_aptx_t;
 
+typedef struct {
+	a2dp_vendor_codec_t info;
+	uint8_t direction;
+	uint8_t source_frequency:4;
+	uint8_t sink_frequency:4;
+} __attribute__ ((packed)) a2dp_faststream_t;
+
+typedef struct {
+	a2dp_vendor_codec_t info;
+	uint8_t frequency:4;
+	uint8_t channel_mode:4;
+	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;
+
+typedef struct {
+	a2dp_vendor_codec_t info;
+	uint8_t frequency:4;
+	uint8_t channel_mode:4;
+	uint8_t reserved0;
+	uint8_t reserved1;
+	uint8_t reserved2;
+	uint8_t reserved3;
+} __attribute__ ((packed)) a2dp_aptx_hd_t;
+
 #else
 #error "Unknown byte order"
 #endif
-- 
2.11.0


  parent reply	other threads:[~2018-12-23 10:41 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-19 16:50 [PATCH 00/10] A2DP: Fix endianity and define new A2DP codecs Pali Rohár
2018-12-19 16:51 ` [PATCH 01/10] avinfo: Fix buffer overflow when parsing broken/malicious data Pali Rohár
2018-12-19 16:51 ` [PATCH 02/10] avinfo: Show Vendor Specific Data Pali Rohár
2018-12-19 16:51 ` [PATCH 03/10] a2dp-codecs: Add SBC prefix for MIN/MAX_BITPOOL constants Pali Rohár
2018-12-19 16:51 ` [PATCH 04/10] a2dp-codecs: Fix codec id for ATRAC Pali Rohár
2018-12-19 16:51 ` [PATCH 05/10] a2dp-codecs & avinfo: Fix parsing MPEG bit rate values Pali Rohár
2018-12-19 16:51 ` [PATCH 06/10] a2dp-codecs: Define a2dp_vendor_codec_t struct in endian neutral way Pali Rohár
2018-12-19 16:51 ` [PATCH 07/10] a2dp-codecs: Add needed includes and properly check for endian macros Pali Rohár
2018-12-19 16:51 ` [PATCH 08/10] a2dp-codecs: Properly define macros and struct for LDAC codec Pali Rohár
2018-12-19 16:51 ` [PATCH 09/10] a2dp-codecs: Add macros and structures for FastStream, aptX Low Latency and aptX HD codecs Pali Rohár
2018-12-19 16:51 ` [PATCH 10/10] avinfo: Parse information about A2DP codecs: FastStream, aptX Low Latency, aptX HD and LDAC Pali Rohár
2018-12-22 22:54 ` [PATCH 00/10] A2DP: Fix endianity and define new A2DP codecs Luiz Augusto von Dentz
2018-12-23  9:30   ` Pali Rohár
2018-12-23 10:40 ` [PATCH v2 " Pali Rohár
2018-12-23 10:40   ` [PATCH v2 01/10] avinfo: Fix buffer overflow when parsing broken/malicious data Pali Rohár
2018-12-23 10:40   ` [PATCH v2 02/10] avinfo: Show Vendor Specific Data Pali Rohár
2018-12-23 10:40   ` [PATCH v2 03/10] a2dp-codecs: Add SBC prefix for MIN/MAX_BITPOOL constants Pali Rohár
2018-12-23 10:40   ` [PATCH v2 04/10] a2dp-codecs: Fix codec id for ATRAC Pali Rohár
2018-12-23 10:40   ` [PATCH v2 05/10] a2dp-codecs & avinfo: Fix parsing MPEG bit rate values Pali Rohár
2018-12-23 10:40   ` [PATCH v2 06/10] a2dp-codecs: Define a2dp_vendor_codec_t struct in endian neutral way Pali Rohár
2018-12-23 10:40   ` [PATCH v2 07/10] a2dp-codecs: Add needed includes and properly check for endian macros Pali Rohár
2018-12-23 10:40   ` [PATCH v2 08/10] a2dp-codecs: Properly define macros and struct for LDAC codec Pali Rohár
2018-12-23 10:40   ` Pali Rohár [this message]
2018-12-23 10:40   ` [PATCH v2 10/10] avinfo: Parse new A2DP codecs Pali Rohár
2018-12-28 18:23   ` [PATCH v2 00/10] A2DP: Fix endianity and define " Luiz Augusto von Dentz
2018-12-28 18:59     ` Pali Rohár

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181223104021.18620-10-pali.rohar@gmail.com \
    --to=pali.rohar@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox