^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) * HDMI Channel map support helpers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <sound/control.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <sound/tlv.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <sound/hda_chmap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * CEA speaker placement:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * FLH FCH FRH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * FLW FL FLC FC FRC FR FRW
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * LFE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * TC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * RL RLC RC RRC RR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * The Left/Right Surround channel _notions_ LS/RS in SMPTE 320M corresponds to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * CEA RL/RR; The SMPTE channel _assignment_ C/LFE is swapped to CEA LFE/FC.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) enum cea_speaker_placement {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) FL = (1 << 0), /* Front Left */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) FC = (1 << 1), /* Front Center */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) FR = (1 << 2), /* Front Right */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) FLC = (1 << 3), /* Front Left Center */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) FRC = (1 << 4), /* Front Right Center */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) RL = (1 << 5), /* Rear Left */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) RC = (1 << 6), /* Rear Center */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) RR = (1 << 7), /* Rear Right */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) RLC = (1 << 8), /* Rear Left Center */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) RRC = (1 << 9), /* Rear Right Center */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) LFE = (1 << 10), /* Low Frequency Effect */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) FLW = (1 << 11), /* Front Left Wide */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) FRW = (1 << 12), /* Front Right Wide */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) FLH = (1 << 13), /* Front Left High */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) FCH = (1 << 14), /* Front Center High */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) FRH = (1 << 15), /* Front Right High */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) TC = (1 << 16), /* Top Center */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) static const char * const cea_speaker_allocation_names[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) /* 0 */ "FL/FR",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) /* 1 */ "LFE",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) /* 2 */ "FC",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) /* 3 */ "RL/RR",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) /* 4 */ "RC",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) /* 5 */ "FLC/FRC",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) /* 6 */ "RLC/RRC",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) /* 7 */ "FLW/FRW",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) /* 8 */ "FLH/FRH",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) /* 9 */ "TC",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) /* 10 */ "FCH",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) * ELD SA bits in the CEA Speaker Allocation data block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) static const int eld_speaker_allocation_bits[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) [0] = FL | FR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) [1] = LFE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) [2] = FC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) [3] = RL | RR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) [4] = RC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) [5] = FLC | FRC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) [6] = RLC | RRC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) /* the following are not defined in ELD yet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) [7] = FLW | FRW,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) [8] = FLH | FRH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) [9] = TC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) [10] = FCH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) * ALSA sequence is:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) * surround40 surround41 surround50 surround51 surround71
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) * ch0 front left = = = =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) * ch1 front right = = = =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) * ch2 rear left = = = =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) * ch3 rear right = = = =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) * ch4 LFE center center center
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) * ch5 LFE LFE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) * ch6 side left
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) * ch7 side right
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) * surround71 = {FL, FR, RLC, RRC, FC, LFE, RL, RR}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) static int hdmi_channel_mapping[0x32][8] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) /* stereo */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) [0x00] = { 0x00, 0x11, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) /* 2.1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) [0x01] = { 0x00, 0x11, 0x22, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) /* Dolby Surround */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) [0x02] = { 0x00, 0x11, 0x23, 0xf2, 0xf4, 0xf5, 0xf6, 0xf7 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) /* surround40 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) [0x08] = { 0x00, 0x11, 0x24, 0x35, 0xf3, 0xf2, 0xf6, 0xf7 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) /* 4ch */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) [0x03] = { 0x00, 0x11, 0x23, 0x32, 0x44, 0xf5, 0xf6, 0xf7 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) /* surround41 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) [0x09] = { 0x00, 0x11, 0x24, 0x35, 0x42, 0xf3, 0xf6, 0xf7 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) /* surround50 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) [0x0a] = { 0x00, 0x11, 0x24, 0x35, 0x43, 0xf2, 0xf6, 0xf7 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) /* surround51 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) [0x0b] = { 0x00, 0x11, 0x24, 0x35, 0x43, 0x52, 0xf6, 0xf7 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) /* 7.1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) [0x13] = { 0x00, 0x11, 0x26, 0x37, 0x43, 0x52, 0x64, 0x75 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) * This is an ordered list!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) * The preceding ones have better chances to be selected by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) * hdmi_channel_allocation().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) static struct hdac_cea_channel_speaker_allocation channel_allocations[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) /* channel: 7 6 5 4 3 2 1 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) { .ca_index = 0x00, .speakers = { 0, 0, 0, 0, 0, 0, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) /* 2.1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) { .ca_index = 0x01, .speakers = { 0, 0, 0, 0, 0, LFE, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) /* Dolby Surround */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) { .ca_index = 0x02, .speakers = { 0, 0, 0, 0, FC, 0, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) /* surround40 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) { .ca_index = 0x08, .speakers = { 0, 0, RR, RL, 0, 0, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) /* surround41 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) { .ca_index = 0x09, .speakers = { 0, 0, RR, RL, 0, LFE, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) /* surround50 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) { .ca_index = 0x0a, .speakers = { 0, 0, RR, RL, FC, 0, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) /* surround51 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) { .ca_index = 0x0b, .speakers = { 0, 0, RR, RL, FC, LFE, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) /* 6.1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) { .ca_index = 0x0f, .speakers = { 0, RC, RR, RL, FC, LFE, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) /* surround71 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) { .ca_index = 0x13, .speakers = { RRC, RLC, RR, RL, FC, LFE, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) { .ca_index = 0x03, .speakers = { 0, 0, 0, 0, FC, LFE, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) { .ca_index = 0x04, .speakers = { 0, 0, 0, RC, 0, 0, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) { .ca_index = 0x05, .speakers = { 0, 0, 0, RC, 0, LFE, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) { .ca_index = 0x06, .speakers = { 0, 0, 0, RC, FC, 0, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) { .ca_index = 0x07, .speakers = { 0, 0, 0, RC, FC, LFE, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) { .ca_index = 0x0c, .speakers = { 0, RC, RR, RL, 0, 0, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) { .ca_index = 0x0d, .speakers = { 0, RC, RR, RL, 0, LFE, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) { .ca_index = 0x0e, .speakers = { 0, RC, RR, RL, FC, 0, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) { .ca_index = 0x10, .speakers = { RRC, RLC, RR, RL, 0, 0, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) { .ca_index = 0x11, .speakers = { RRC, RLC, RR, RL, 0, LFE, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) { .ca_index = 0x12, .speakers = { RRC, RLC, RR, RL, FC, 0, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) { .ca_index = 0x14, .speakers = { FRC, FLC, 0, 0, 0, 0, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) { .ca_index = 0x15, .speakers = { FRC, FLC, 0, 0, 0, LFE, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) { .ca_index = 0x16, .speakers = { FRC, FLC, 0, 0, FC, 0, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) { .ca_index = 0x17, .speakers = { FRC, FLC, 0, 0, FC, LFE, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) { .ca_index = 0x18, .speakers = { FRC, FLC, 0, RC, 0, 0, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) { .ca_index = 0x19, .speakers = { FRC, FLC, 0, RC, 0, LFE, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) { .ca_index = 0x1a, .speakers = { FRC, FLC, 0, RC, FC, 0, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) { .ca_index = 0x1b, .speakers = { FRC, FLC, 0, RC, FC, LFE, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) { .ca_index = 0x1c, .speakers = { FRC, FLC, RR, RL, 0, 0, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) { .ca_index = 0x1d, .speakers = { FRC, FLC, RR, RL, 0, LFE, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) { .ca_index = 0x1e, .speakers = { FRC, FLC, RR, RL, FC, 0, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) { .ca_index = 0x1f, .speakers = { FRC, FLC, RR, RL, FC, LFE, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) { .ca_index = 0x20, .speakers = { 0, FCH, RR, RL, FC, 0, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) { .ca_index = 0x21, .speakers = { 0, FCH, RR, RL, FC, LFE, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) { .ca_index = 0x22, .speakers = { TC, 0, RR, RL, FC, 0, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) { .ca_index = 0x23, .speakers = { TC, 0, RR, RL, FC, LFE, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) { .ca_index = 0x24, .speakers = { FRH, FLH, RR, RL, 0, 0, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) { .ca_index = 0x25, .speakers = { FRH, FLH, RR, RL, 0, LFE, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) { .ca_index = 0x26, .speakers = { FRW, FLW, RR, RL, 0, 0, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) { .ca_index = 0x27, .speakers = { FRW, FLW, RR, RL, 0, LFE, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) { .ca_index = 0x28, .speakers = { TC, RC, RR, RL, FC, 0, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) { .ca_index = 0x29, .speakers = { TC, RC, RR, RL, FC, LFE, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) { .ca_index = 0x2a, .speakers = { FCH, RC, RR, RL, FC, 0, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) { .ca_index = 0x2b, .speakers = { FCH, RC, RR, RL, FC, LFE, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) { .ca_index = 0x2c, .speakers = { TC, FCH, RR, RL, FC, 0, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) { .ca_index = 0x2d, .speakers = { TC, FCH, RR, RL, FC, LFE, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) { .ca_index = 0x2e, .speakers = { FRH, FLH, RR, RL, FC, 0, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) { .ca_index = 0x2f, .speakers = { FRH, FLH, RR, RL, FC, LFE, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) { .ca_index = 0x30, .speakers = { FRW, FLW, RR, RL, FC, 0, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) { .ca_index = 0x31, .speakers = { FRW, FLW, RR, RL, FC, LFE, FR, FL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) static int hdmi_pin_set_slot_channel(struct hdac_device *codec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) hda_nid_t pin_nid, int asp_slot, int channel)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) return snd_hdac_codec_write(codec, pin_nid, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) AC_VERB_SET_HDMI_CHAN_SLOT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) (channel << 4) | asp_slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) static int hdmi_pin_get_slot_channel(struct hdac_device *codec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) hda_nid_t pin_nid, int asp_slot)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) return (snd_hdac_codec_read(codec, pin_nid, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) AC_VERB_GET_HDMI_CHAN_SLOT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) asp_slot) & 0xf0) >> 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) static int hdmi_get_channel_count(struct hdac_device *codec, hda_nid_t cvt_nid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) return 1 + snd_hdac_codec_read(codec, cvt_nid, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) AC_VERB_GET_CVT_CHAN_COUNT, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) static void hdmi_set_channel_count(struct hdac_device *codec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) hda_nid_t cvt_nid, int chs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) if (chs != hdmi_get_channel_count(codec, cvt_nid))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) snd_hdac_codec_write(codec, cvt_nid, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) AC_VERB_SET_CVT_CHAN_COUNT, chs - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) * Channel mapping routines
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) */
^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) * Compute derived values in channel_allocations[].
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) static void init_channel_allocations(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) int i, j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) struct hdac_cea_channel_speaker_allocation *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) for (i = 0; i < ARRAY_SIZE(channel_allocations); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) p = channel_allocations + i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) p->channels = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) p->spk_mask = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) for (j = 0; j < ARRAY_SIZE(p->speakers); j++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) if (p->speakers[j]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) p->channels++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) p->spk_mask |= p->speakers[j];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) static int get_channel_allocation_order(int ca)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) for (i = 0; i < ARRAY_SIZE(channel_allocations); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) if (channel_allocations[i].ca_index == ca)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) return i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) void snd_hdac_print_channel_allocation(int spk_alloc, char *buf, int buflen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) int i, j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) for (i = 0, j = 0; i < ARRAY_SIZE(cea_speaker_allocation_names); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) if (spk_alloc & (1 << i))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) j += scnprintf(buf + j, buflen - j, " %s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) cea_speaker_allocation_names[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) buf[j] = '\0'; /* necessary when j == 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) EXPORT_SYMBOL_GPL(snd_hdac_print_channel_allocation);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) * The transformation takes two steps:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) * eld->spk_alloc => (eld_speaker_allocation_bits[]) => spk_mask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) * spk_mask => (channel_allocations[]) => ai->CA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) * TODO: it could select the wrong CA from multiple candidates.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) static int hdmi_channel_allocation_spk_alloc_blk(struct hdac_device *codec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) int spk_alloc, int channels)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) int ca = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) int spk_mask = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) char buf[SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) * CA defaults to 0 for basic stereo audio
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) if (channels <= 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) * expand ELD's speaker allocation mask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) * ELD tells the speaker mask in a compact(paired) form,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) * expand ELD's notions to match the ones used by Audio InfoFrame.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) for (i = 0; i < ARRAY_SIZE(eld_speaker_allocation_bits); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) if (spk_alloc & (1 << i))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) spk_mask |= eld_speaker_allocation_bits[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) /* search for the first working match in the CA table */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) for (i = 0; i < ARRAY_SIZE(channel_allocations); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) if (channels == channel_allocations[i].channels &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) (spk_mask & channel_allocations[i].spk_mask) ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) channel_allocations[i].spk_mask) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) ca = channel_allocations[i].ca_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) if (!ca) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) * if there was no match, select the regular ALSA channel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) * allocation with the matching number of channels
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) for (i = 0; i < ARRAY_SIZE(channel_allocations); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) if (channels == channel_allocations[i].channels) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) ca = channel_allocations[i].ca_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) snd_hdac_print_channel_allocation(spk_alloc, buf, sizeof(buf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) dev_dbg(&codec->dev, "HDMI: select CA 0x%x for %d-channel allocation: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) ca, channels, buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) return ca;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) static void hdmi_debug_channel_mapping(struct hdac_chmap *chmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) hda_nid_t pin_nid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) #ifdef CONFIG_SND_DEBUG_VERBOSE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) int channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) for (i = 0; i < 8; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) channel = chmap->ops.pin_get_slot_channel(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) chmap->hdac, pin_nid, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) dev_dbg(&chmap->hdac->dev, "HDMI: ASP channel %d => slot %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) channel, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) static void hdmi_std_setup_channel_mapping(struct hdac_chmap *chmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) hda_nid_t pin_nid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) bool non_pcm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) int ca)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) struct hdac_cea_channel_speaker_allocation *ch_alloc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) int order;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) int non_pcm_mapping[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) order = get_channel_allocation_order(ca);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) ch_alloc = &channel_allocations[order];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) if (hdmi_channel_mapping[ca][1] == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) int hdmi_slot = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) /* fill actual channel mappings in ALSA channel (i) order */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) for (i = 0; i < ch_alloc->channels; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) while (!WARN_ON(hdmi_slot >= 8) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) !ch_alloc->speakers[7 - hdmi_slot])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) hdmi_slot++; /* skip zero slots */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) hdmi_channel_mapping[ca][i] = (i << 4) | hdmi_slot++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) /* fill the rest of the slots with ALSA channel 0xf */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) for (hdmi_slot = 0; hdmi_slot < 8; hdmi_slot++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) if (!ch_alloc->speakers[7 - hdmi_slot])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) hdmi_channel_mapping[ca][i++] = (0xf << 4) | hdmi_slot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) if (non_pcm) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) for (i = 0; i < ch_alloc->channels; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) non_pcm_mapping[i] = (i << 4) | i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) for (; i < 8; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) non_pcm_mapping[i] = (0xf << 4) | i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) for (i = 0; i < 8; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) int slotsetup = non_pcm ? non_pcm_mapping[i] : hdmi_channel_mapping[ca][i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) int hdmi_slot = slotsetup & 0x0f;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) int channel = (slotsetup & 0xf0) >> 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) err = chmap->ops.pin_set_slot_channel(chmap->hdac,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) pin_nid, hdmi_slot, channel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) dev_dbg(&chmap->hdac->dev, "HDMI: channel mapping failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) struct channel_map_table {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) unsigned char map; /* ALSA API channel map position */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) int spk_mask; /* speaker position bit mask */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) static struct channel_map_table map_tables[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) { SNDRV_CHMAP_FL, FL },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) { SNDRV_CHMAP_FR, FR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) { SNDRV_CHMAP_RL, RL },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) { SNDRV_CHMAP_RR, RR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) { SNDRV_CHMAP_LFE, LFE },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) { SNDRV_CHMAP_FC, FC },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) { SNDRV_CHMAP_RLC, RLC },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) { SNDRV_CHMAP_RRC, RRC },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) { SNDRV_CHMAP_RC, RC },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) { SNDRV_CHMAP_FLC, FLC },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) { SNDRV_CHMAP_FRC, FRC },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) { SNDRV_CHMAP_TFL, FLH },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) { SNDRV_CHMAP_TFR, FRH },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) { SNDRV_CHMAP_FLW, FLW },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) { SNDRV_CHMAP_FRW, FRW },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) { SNDRV_CHMAP_TC, TC },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) { SNDRV_CHMAP_TFC, FCH },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) {} /* terminator */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) /* from ALSA API channel position to speaker bit mask */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) int snd_hdac_chmap_to_spk_mask(unsigned char c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) struct channel_map_table *t = map_tables;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) for (; t->map; t++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) if (t->map == c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) return t->spk_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) EXPORT_SYMBOL_GPL(snd_hdac_chmap_to_spk_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) /* from ALSA API channel position to CEA slot */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) static int to_cea_slot(int ordered_ca, unsigned char pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) int mask = snd_hdac_chmap_to_spk_mask(pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) /* Add sanity check to pass klockwork check.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) * This should never happen.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) if (ordered_ca >= ARRAY_SIZE(channel_allocations))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) if (mask) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) for (i = 0; i < 8; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) if (channel_allocations[ordered_ca].speakers[7 - i] == mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) return i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) /* from speaker bit mask to ALSA API channel position */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) int snd_hdac_spk_to_chmap(int spk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) struct channel_map_table *t = map_tables;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) for (; t->map; t++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) if (t->spk_mask == spk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) return t->map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) EXPORT_SYMBOL_GPL(snd_hdac_spk_to_chmap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) /* from CEA slot to ALSA API channel position */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) static int from_cea_slot(int ordered_ca, unsigned char slot)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) int mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) /* Add sanity check to pass klockwork check.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) * This should never happen.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) if (slot >= 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) mask = channel_allocations[ordered_ca].speakers[7 - slot];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) return snd_hdac_spk_to_chmap(mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) /* get the CA index corresponding to the given ALSA API channel map */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) static int hdmi_manual_channel_allocation(int chs, unsigned char *map)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) int i, spks = 0, spk_mask = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) for (i = 0; i < chs; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) int mask = snd_hdac_chmap_to_spk_mask(map[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) if (mask) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) spk_mask |= mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) spks++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) for (i = 0; i < ARRAY_SIZE(channel_allocations); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) if ((chs == channel_allocations[i].channels ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) spks == channel_allocations[i].channels) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) (spk_mask & channel_allocations[i].spk_mask) ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) channel_allocations[i].spk_mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) return channel_allocations[i].ca_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) /* set up the channel slots for the given ALSA API channel map */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) static int hdmi_manual_setup_channel_mapping(struct hdac_chmap *chmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) hda_nid_t pin_nid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) int chs, unsigned char *map,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) int ca)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) int ordered_ca = get_channel_allocation_order(ca);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) int alsa_pos, hdmi_slot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) int assignments[8] = {[0 ... 7] = 0xf};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) for (alsa_pos = 0; alsa_pos < chs; alsa_pos++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) hdmi_slot = to_cea_slot(ordered_ca, map[alsa_pos]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) if (hdmi_slot < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) continue; /* unassigned channel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) assignments[hdmi_slot] = alsa_pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) for (hdmi_slot = 0; hdmi_slot < 8; hdmi_slot++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) err = chmap->ops.pin_set_slot_channel(chmap->hdac,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) pin_nid, hdmi_slot, assignments[hdmi_slot]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) /* store ALSA API channel map from the current default map */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) static void hdmi_setup_fake_chmap(unsigned char *map, int ca)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) int ordered_ca = get_channel_allocation_order(ca);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) for (i = 0; i < 8; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) if (ordered_ca < ARRAY_SIZE(channel_allocations) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) i < channel_allocations[ordered_ca].channels)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) map[i] = from_cea_slot(ordered_ca, hdmi_channel_mapping[ca][i] & 0x0f);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) map[i] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) void snd_hdac_setup_channel_mapping(struct hdac_chmap *chmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) hda_nid_t pin_nid, bool non_pcm, int ca,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) int channels, unsigned char *map,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) bool chmap_set)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) if (!non_pcm && chmap_set) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) hdmi_manual_setup_channel_mapping(chmap, pin_nid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) channels, map, ca);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) hdmi_std_setup_channel_mapping(chmap, pin_nid, non_pcm, ca);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) hdmi_setup_fake_chmap(map, ca);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) hdmi_debug_channel_mapping(chmap, pin_nid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) EXPORT_SYMBOL_GPL(snd_hdac_setup_channel_mapping);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) int snd_hdac_get_active_channels(int ca)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) int ordered_ca = get_channel_allocation_order(ca);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) /* Add sanity check to pass klockwork check.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) * This should never happen.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) if (ordered_ca >= ARRAY_SIZE(channel_allocations))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) ordered_ca = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) return channel_allocations[ordered_ca].channels;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) EXPORT_SYMBOL_GPL(snd_hdac_get_active_channels);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) struct hdac_cea_channel_speaker_allocation *snd_hdac_get_ch_alloc_from_ca(int ca)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) return &channel_allocations[get_channel_allocation_order(ca)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) EXPORT_SYMBOL_GPL(snd_hdac_get_ch_alloc_from_ca);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) int snd_hdac_channel_allocation(struct hdac_device *hdac, int spk_alloc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) int channels, bool chmap_set, bool non_pcm, unsigned char *map)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) int ca;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) if (!non_pcm && chmap_set)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) ca = hdmi_manual_channel_allocation(channels, map);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) ca = hdmi_channel_allocation_spk_alloc_blk(hdac,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) spk_alloc, channels);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) if (ca < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) ca = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) return ca;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) EXPORT_SYMBOL_GPL(snd_hdac_channel_allocation);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) * ALSA API channel-map control callbacks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) static int hdmi_chmap_ctl_info(struct snd_kcontrol *kcontrol,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) struct snd_ctl_elem_info *uinfo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) struct hdac_chmap *chmap = info->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) uinfo->count = chmap->channels_max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) uinfo->value.integer.min = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) uinfo->value.integer.max = SNDRV_CHMAP_LAST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) static int hdmi_chmap_cea_alloc_validate_get_type(struct hdac_chmap *chmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) struct hdac_cea_channel_speaker_allocation *cap, int channels)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) /* If the speaker allocation matches the channel count, it is OK.*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) if (cap->channels != channels)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) /* all channels are remappable freely */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) return SNDRV_CTL_TLVT_CHMAP_VAR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) static void hdmi_cea_alloc_to_tlv_chmap(struct hdac_chmap *hchmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) struct hdac_cea_channel_speaker_allocation *cap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) unsigned int *chmap, int channels)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) int count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) int c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) for (c = 7; c >= 0; c--) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) int spk = cap->speakers[c];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) if (!spk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) chmap[count++] = snd_hdac_spk_to_chmap(spk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) WARN_ON(count != channels);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) static int spk_mask_from_spk_alloc(int spk_alloc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) int spk_mask = eld_speaker_allocation_bits[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) for (i = 0; i < ARRAY_SIZE(eld_speaker_allocation_bits); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) if (spk_alloc & (1 << i))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) spk_mask |= eld_speaker_allocation_bits[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) return spk_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) static int hdmi_chmap_ctl_tlv(struct snd_kcontrol *kcontrol, int op_flag,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) unsigned int size, unsigned int __user *tlv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) struct hdac_chmap *chmap = info->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) int pcm_idx = kcontrol->private_value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) unsigned int __user *dst;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) int chs, count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) unsigned long max_chs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) int type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) int spk_alloc, spk_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) if (size < 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) if (put_user(SNDRV_CTL_TLVT_CONTAINER, tlv))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) size -= 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) dst = tlv + 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) spk_alloc = chmap->ops.get_spk_alloc(chmap->hdac, pcm_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) spk_mask = spk_mask_from_spk_alloc(spk_alloc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) max_chs = hweight_long(spk_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) for (chs = 2; chs <= max_chs; chs++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) struct hdac_cea_channel_speaker_allocation *cap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) cap = channel_allocations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) for (i = 0; i < ARRAY_SIZE(channel_allocations); i++, cap++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) int chs_bytes = chs * 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) unsigned int tlv_chmap[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) if (cap->channels != chs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) if (!(cap->spk_mask == (spk_mask & cap->spk_mask)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) type = chmap->ops.chmap_cea_alloc_validate_get_type(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) chmap, cap, chs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) if (type < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) if (size < 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) if (put_user(type, dst) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) put_user(chs_bytes, dst + 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) dst += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) size -= 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) count += 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) if (size < chs_bytes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) size -= chs_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) count += chs_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) chmap->ops.cea_alloc_to_tlv_chmap(chmap, cap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) tlv_chmap, chs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) if (copy_to_user(dst, tlv_chmap, chs_bytes))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) dst += chs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) if (put_user(count, tlv + 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) static int hdmi_chmap_ctl_get(struct snd_kcontrol *kcontrol,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) struct snd_ctl_elem_value *ucontrol)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) struct hdac_chmap *chmap = info->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) int pcm_idx = kcontrol->private_value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) unsigned char pcm_chmap[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) memset(pcm_chmap, 0, sizeof(pcm_chmap));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) chmap->ops.get_chmap(chmap->hdac, pcm_idx, pcm_chmap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) for (i = 0; i < ARRAY_SIZE(pcm_chmap); i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) ucontrol->value.integer.value[i] = pcm_chmap[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) static int hdmi_chmap_ctl_put(struct snd_kcontrol *kcontrol,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) struct snd_ctl_elem_value *ucontrol)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) struct hdac_chmap *hchmap = info->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) int pcm_idx = kcontrol->private_value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) unsigned int ctl_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) struct snd_pcm_substream *substream;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) unsigned char chmap[8], per_pin_chmap[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) int i, err, ca, prepared = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) /* No monitor is connected in dyn_pcm_assign.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) * It's invalid to setup the chmap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) if (!hchmap->ops.is_pcm_attached(hchmap->hdac, pcm_idx))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) ctl_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) substream = snd_pcm_chmap_substream(info, ctl_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) if (!substream || !substream->runtime)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) return 0; /* just for avoiding error from alsactl restore */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) switch (substream->runtime->status->state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) case SNDRV_PCM_STATE_OPEN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) case SNDRV_PCM_STATE_SETUP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) case SNDRV_PCM_STATE_PREPARED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) prepared = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) memset(chmap, 0, sizeof(chmap));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) for (i = 0; i < ARRAY_SIZE(chmap); i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) chmap[i] = ucontrol->value.integer.value[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) hchmap->ops.get_chmap(hchmap->hdac, pcm_idx, per_pin_chmap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) if (!memcmp(chmap, per_pin_chmap, sizeof(chmap)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) ca = hdmi_manual_channel_allocation(ARRAY_SIZE(chmap), chmap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) if (ca < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) if (hchmap->ops.chmap_validate) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) err = hchmap->ops.chmap_validate(hchmap, ca,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) ARRAY_SIZE(chmap), chmap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) hchmap->ops.set_chmap(hchmap->hdac, pcm_idx, chmap, prepared);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) static const struct hdac_chmap_ops chmap_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) .chmap_cea_alloc_validate_get_type = hdmi_chmap_cea_alloc_validate_get_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) .cea_alloc_to_tlv_chmap = hdmi_cea_alloc_to_tlv_chmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) .pin_get_slot_channel = hdmi_pin_get_slot_channel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) .pin_set_slot_channel = hdmi_pin_set_slot_channel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) .set_channel_count = hdmi_set_channel_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) void snd_hdac_register_chmap_ops(struct hdac_device *hdac,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) struct hdac_chmap *chmap)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) chmap->ops = chmap_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) chmap->hdac = hdac;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) init_channel_allocations();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) EXPORT_SYMBOL_GPL(snd_hdac_register_chmap_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) int snd_hdac_add_chmap_ctls(struct snd_pcm *pcm, int pcm_idx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) struct hdac_chmap *hchmap)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) struct snd_pcm_chmap *chmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) struct snd_kcontrol *kctl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) int err, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) err = snd_pcm_add_chmap_ctls(pcm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) SNDRV_PCM_STREAM_PLAYBACK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) NULL, 0, pcm_idx, &chmap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) /* override handlers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) chmap->private_data = hchmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) kctl = chmap->kctl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) for (i = 0; i < kctl->count; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) kctl->vd[i].access |= SNDRV_CTL_ELEM_ACCESS_WRITE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) kctl->info = hdmi_chmap_ctl_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) kctl->get = hdmi_chmap_ctl_get;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) kctl->put = hdmi_chmap_ctl_put;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) kctl->tlv.c = hdmi_chmap_ctl_tlv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) EXPORT_SYMBOL_GPL(snd_hdac_add_chmap_ctls);