[PATCH 2/3] avrcp: Factor out function to handle vendordep pdu

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

 



In order to support vendordep pdu as required by AVRCP 1.3 this part
will get very large. So, separate it to a new function like is done for
panel_passthrough.
---
 audio/control.c |   39 ++++++++++++++++++++++++---------------
 1 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/audio/control.c b/audio/control.c
index 57a4edc..9202966 100644
--- a/audio/control.c
+++ b/audio/control.c
@@ -419,6 +419,26 @@ static void handle_panel_passthrough(struct control *control,
 						operands[0] & 0x7F, status);
 }
 
+/* handle vendordep pdu inside an avctp packet */
+static int handle_vendordep_pdu(struct control *control,
+					struct avrcp_header *avrcp,
+					int operand_count)
+{
+	struct avrcp_spec_avc_pdu *pdu = (void *)(avrcp) +
+						AVRCP_SPECAVCPDU_HEADER_LENGTH;
+
+	/* Reply with REJECT msg with error code 0x0
+	 * (Invalid Command) as defined in AVRCP spec (6.15.1) */
+	avrcp->code = CTYPE_REJECTED;
+
+	pdu->packet_type = 0;
+	pdu->rsvd = 0;
+	pdu->params[0] = 0; /* invalid command */
+	pdu->params_len = htons(1);
+
+	return AVRCP_HEADER_LENGTH + AVRCP_SPECAVCPDU_HEADER_LENGTH + 1;
+}
+
 static void avctp_disconnected(struct audio_device *dev)
 {
 	struct control *control = dev->control;
@@ -592,22 +612,11 @@ static gboolean control_cb(GIOChannel *chan, GIOCondition cond,
 				"OP_UNITINFO" : "OP_SUBUNITINFO");
 	} else if (avctp->cr == AVCTP_COMMAND &&
 			avrcp->opcode == OP_VENDORDEP) {
-		/* Reply with REJECT msg with error code 0x0
-		 * (Invalid Command) as defined in AVRCP spec (6.15.1) */
-		struct avrcp_spec_avc_pdu *pdu = (void *) operands;
-
+		int r_size;
+		operand_count -= 3;
 		avctp->cr = AVCTP_RESPONSE;
-		avrcp->code = CTYPE_REJECTED;
-
-		pdu->packet_type = 0;
-		pdu->rsvd = 0;
-		pdu->params[0] = 0; /* invalid command */
-		pdu->params_len = htons(1);
-
-		packet_size =  sizeof(struct avctp_header)
-					+ sizeof(struct avrcp_header)
-					+ sizeof(struct avrcp_spec_avc_pdu)
-					+ 1;
+		r_size = handle_vendordep_pdu(control, avrcp, operand_count);
+		packet_size = AVCTP_HEADER_LENGTH + r_size;
 	} else {
 		avctp->cr = AVCTP_RESPONSE;
 		avrcp->code = CTYPE_REJECTED;
-- 
1.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[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