Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * bebob_command.c - driver for BeBoB based devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (c) 2013-2014 Takashi Sakamoto
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include "./bebob.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) int avc_audio_set_selector(struct fw_unit *unit, unsigned int subunit_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 			   unsigned int fb_id, unsigned int num)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 	u8 *buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 	buf = kzalloc(12, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 	if (buf == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 	buf[0]  = 0x00;		/* AV/C CONTROL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	buf[1]  = 0x08 | (0x07 & subunit_id);	/* AUDIO SUBUNIT ID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	buf[2]  = 0xb8;		/* FUNCTION BLOCK  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	buf[3]  = 0x80;		/* type is 'selector'*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	buf[4]  = 0xff & fb_id;	/* function block id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	buf[5]  = 0x10;		/* control attribute is CURRENT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	buf[6]  = 0x02;		/* selector length is 2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	buf[7]  = 0xff & num;	/* input function block plug number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	buf[8]  = 0x01;		/* control selector is SELECTOR_CONTROL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	err = fcp_avc_transaction(unit, buf, 12, buf, 12,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 				  BIT(1) | BIT(2) | BIT(3) | BIT(4) | BIT(5) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 				  BIT(6) | BIT(7) | BIT(8));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 		;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	else if (err < 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 		err = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	else if (buf[0] == 0x08) /* NOT IMPLEMENTED */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 		err = -ENOSYS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	else if (buf[0] == 0x0a) /* REJECTED */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 		err = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 		err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	kfree(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) int avc_audio_get_selector(struct fw_unit *unit, unsigned int subunit_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 			   unsigned int fb_id, unsigned int *num)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	u8 *buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	buf = kzalloc(12, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	if (buf == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	buf[0]  = 0x01;		/* AV/C STATUS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	buf[1]  = 0x08 | (0x07 & subunit_id);	/* AUDIO SUBUNIT ID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	buf[2]  = 0xb8;		/* FUNCTION BLOCK */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	buf[3]  = 0x80;		/* type is 'selector'*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	buf[4]  = 0xff & fb_id;	/* function block id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	buf[5]  = 0x10;		/* control attribute is CURRENT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	buf[6]  = 0x02;		/* selector length is 2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	buf[7]  = 0xff;		/* input function block plug number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	buf[8]  = 0x01;		/* control selector is SELECTOR_CONTROL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	err = fcp_avc_transaction(unit, buf, 12, buf, 12,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 				  BIT(1) | BIT(2) | BIT(3) | BIT(4) | BIT(5) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 				  BIT(6) | BIT(8));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	else if (err < 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 		err = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	else if (buf[0] == 0x08) /* NOT IMPLEMENTED */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		err = -ENOSYS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	else if (buf[0] == 0x0a) /* REJECTED */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 		err = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	else if (buf[0] == 0x0b) /* IN TRANSITION */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		err = -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		goto end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	*num = buf[7];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) end:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	kfree(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) avc_bridgeco_fill_extension_addr(u8 *buf, u8 *addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	buf[1] = addr[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	memcpy(buf + 4, addr + 1, 5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) avc_bridgeco_fill_plug_info_extension_command(u8 *buf, u8 *addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 					      unsigned int itype)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	buf[0] = 0x01;	/* AV/C STATUS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	buf[2] = 0x02;	/* AV/C GENERAL PLUG INFO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	buf[3] = 0xc0;	/* BridgeCo extension */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	avc_bridgeco_fill_extension_addr(buf, addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	buf[9] = itype;	/* info type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) int avc_bridgeco_get_plug_type(struct fw_unit *unit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 			       u8 addr[AVC_BRIDGECO_ADDR_BYTES],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 			       enum avc_bridgeco_plug_type *type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	u8 *buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	buf = kzalloc(12, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	if (buf == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	/* Info type is 'plug type'. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	avc_bridgeco_fill_plug_info_extension_command(buf, addr, 0x00);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	err = fcp_avc_transaction(unit, buf, 12, buf, 12,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 				  BIT(1) | BIT(2) | BIT(3) | BIT(4) | BIT(5) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 				  BIT(6) | BIT(7) | BIT(9));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	else if (err < 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		err = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	else if (buf[0] == 0x08) /* NOT IMPLEMENTED */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		err = -ENOSYS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	else if (buf[0] == 0x0a) /* REJECTED */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		err = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	else if (buf[0] == 0x0b) /* IN TRANSITION */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 		err = -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		goto end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	*type = buf[10];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) end:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	kfree(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) int avc_bridgeco_get_plug_ch_pos(struct fw_unit *unit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 				 u8 addr[AVC_BRIDGECO_ADDR_BYTES],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 				 u8 *buf, unsigned int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	/* Info type is 'channel position'. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	avc_bridgeco_fill_plug_info_extension_command(buf, addr, 0x03);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	err = fcp_avc_transaction(unit, buf, 12, buf, 256,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 				  BIT(1) | BIT(2) | BIT(3) | BIT(4) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 				  BIT(5) | BIT(6) | BIT(7) | BIT(9));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 		;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	else if (err < 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 		err = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	else if (buf[0] == 0x08) /* NOT IMPLEMENTED */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 		err = -ENOSYS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	else if (buf[0] == 0x0a) /* REJECTED */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		err = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	else if (buf[0] == 0x0b) /* IN TRANSITION */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 		err = -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 		goto end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	/* Pick up specific data. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	memmove(buf, buf + 10, err - 10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) end:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) int avc_bridgeco_get_plug_section_type(struct fw_unit *unit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 				       u8 addr[AVC_BRIDGECO_ADDR_BYTES],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 				       unsigned int id, u8 *type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	u8 *buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	/* section info includes charactors but this module don't need it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	buf = kzalloc(12, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	if (buf == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	/* Info type is 'section info'. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	avc_bridgeco_fill_plug_info_extension_command(buf, addr, 0x07);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	buf[10] = 0xff & ++id;	/* section id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	err = fcp_avc_transaction(unit, buf, 12, buf, 12,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 				  BIT(1) | BIT(2) | BIT(3) | BIT(4) | BIT(5) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 				  BIT(6) | BIT(7) | BIT(9) | BIT(10));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	else if (err < 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 		err = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	else if (buf[0] == 0x08) /* NOT IMPLEMENTED */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		err = -ENOSYS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	else if (buf[0] == 0x0a) /* REJECTED */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 		err = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	else if (buf[0] == 0x0b) /* IN TRANSITION */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 		err = -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		goto end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	*type = buf[11];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) end:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	kfree(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) int avc_bridgeco_get_plug_input(struct fw_unit *unit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 				u8 addr[AVC_BRIDGECO_ADDR_BYTES], u8 input[7])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	u8 *buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	buf = kzalloc(18, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	if (buf == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	/* Info type is 'plug input'. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	avc_bridgeco_fill_plug_info_extension_command(buf, addr, 0x05);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	err = fcp_avc_transaction(unit, buf, 16, buf, 16,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 				  BIT(1) | BIT(2) | BIT(3) | BIT(4) | BIT(5) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 				  BIT(6) | BIT(7));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	else if (err < 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 		err = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	else if (buf[0] == 0x08) /* NOT IMPLEMENTED */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 		err = -ENOSYS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	else if (buf[0] == 0x0a) /* REJECTED */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 		err = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	else if (buf[0] == 0x0b) /* IN TRANSITION */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 		err = -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 		goto end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	memcpy(input, buf + 10, 5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) end:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	kfree(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) int avc_bridgeco_get_plug_strm_fmt(struct fw_unit *unit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 				   u8 addr[AVC_BRIDGECO_ADDR_BYTES], u8 *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 				   unsigned int *len, unsigned int eid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	/* check given buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	if ((buf == NULL) || (*len < 12)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 		err = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 		goto end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	buf[0] = 0x01;	/* AV/C STATUS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	buf[2] = 0x2f;	/* AV/C STREAM FORMAT SUPPORT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	buf[3] = 0xc1;	/* Bridgeco extension - List Request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	avc_bridgeco_fill_extension_addr(buf, addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	buf[10] = 0xff & eid;	/* Entry ID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	err = fcp_avc_transaction(unit, buf, 12, buf, *len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 				  BIT(1) | BIT(2) | BIT(3) | BIT(4) | BIT(5) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 				  BIT(6) | BIT(7) | BIT(10));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 		;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	else if (err < 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 		err = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	else if (buf[0] == 0x08)        /* NOT IMPLEMENTED */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 		err = -ENOSYS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	else if (buf[0] == 0x0a)        /* REJECTED */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 		err = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	else if (buf[0] == 0x0b)        /* IN TRANSITION */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 		err = -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	else if (buf[10] != eid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 		err = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 		goto end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	/* Pick up 'stream format info'. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	memmove(buf, buf + 11, err - 11);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	*len = err - 11;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) end:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) }