Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: ab8500-codec: Set rx dai slots from rx_mask

Replace hard coded rx slot numbers from ab8500_codec_set_dai_tdm_slot
using the ones requested by the machine driver in rx_mask instead.

Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

authored by

Fabio Baltieri and committed by
Mark Brown
da33d723 4510dbe3

+35 -29
+20 -9
sound/soc/codecs/ab8500-codec.c
··· 2334 2334 } 2335 2335 2336 2336 /* Setup TDM AD according to active RX-slots */ 2337 + 2338 + if (rx_mask & ~0xff) 2339 + return -EINVAL; 2340 + 2341 + rx_mask = rx_mask << AB8500_AD_DATA0_OFFSET; 2337 2342 slots_active = hweight32(rx_mask); 2343 + 2338 2344 dev_dbg(dai->codec->dev, "%s: Slots, active, RX: %d\n", __func__, 2339 2345 slots_active); 2346 + 2340 2347 switch (slots_active) { 2341 2348 case 0: 2342 2349 break; 2343 2350 case 1: 2344 - /* AD_OUT3 -> slot 0 & 1 */ 2345 - snd_soc_update_bits(codec, AB8500_ADSLOTSEL1, AB8500_MASK_ALL, 2346 - AB8500_ADSLOTSELX_AD_OUT3_TO_SLOT_EVEN | 2347 - AB8500_ADSLOTSELX_AD_OUT3_TO_SLOT_ODD); 2351 + slot = find_first_bit((unsigned long *)&rx_mask, 32); 2352 + snd_soc_update_bits(codec, AB8500_ADSLOTSEL(slot), 2353 + AB8500_MASK_SLOT(slot), 2354 + AB8500_ADSLOTSELX_AD_OUT_TO_SLOT(AB8500_AD_OUT3, slot)); 2348 2355 break; 2349 2356 case 2: 2350 - /* AD_OUT3 -> slot 0, AD_OUT2 -> slot 1 */ 2357 + slot = find_first_bit((unsigned long *)&rx_mask, 32); 2351 2358 snd_soc_update_bits(codec, 2352 - AB8500_ADSLOTSEL1, 2353 - AB8500_MASK_ALL, 2354 - AB8500_ADSLOTSELX_AD_OUT3_TO_SLOT_EVEN | 2355 - AB8500_ADSLOTSELX_AD_OUT2_TO_SLOT_ODD); 2359 + AB8500_ADSLOTSEL(slot), 2360 + AB8500_MASK_SLOT(slot), 2361 + AB8500_ADSLOTSELX_AD_OUT_TO_SLOT(AB8500_AD_OUT3, slot)); 2362 + slot = find_next_bit((unsigned long *)&rx_mask, 32, slot + 1); 2363 + snd_soc_update_bits(codec, 2364 + AB8500_ADSLOTSEL(slot), 2365 + AB8500_MASK_SLOT(slot), 2366 + AB8500_ADSLOTSELX_AD_OUT_TO_SLOT(AB8500_AD_OUT2, slot)); 2356 2367 break; 2357 2368 case 8: 2358 2369 dev_dbg(dai->codec->dev,
+15 -20
sound/soc/codecs/ab8500-codec.h
··· 80 80 #define AB8500_ADSLOTSEL14 0x2C 81 81 #define AB8500_ADSLOTSEL15 0x2D 82 82 #define AB8500_ADSLOTSEL16 0x2E 83 + #define AB8500_ADSLOTSEL(slot) (AB8500_ADSLOTSEL1 + (slot >> 1)) 83 84 #define AB8500_ADSLOTHIZCTRL1 0x2F 84 85 #define AB8500_ADSLOTHIZCTRL2 0x30 85 86 #define AB8500_ADSLOTHIZCTRL3 0x31 ··· 152 151 #define AB8500_CACHEREGNUM (AB8500_LAST_REG + 1) 153 152 154 153 #define AB8500_MASK_ALL 0xFF 154 + #define AB8500_MASK_SLOT(slot) ((slot & 1) ? 0xF0 : 0x0F) 155 155 #define AB8500_MASK_NONE 0x00 156 156 157 157 /* AB8500_POWERUP */ ··· 356 354 #define AB8500_DIGIFCONF4_IF1WL0 0 357 355 358 356 /* AB8500_ADSLOTSELX */ 359 - #define AB8500_ADSLOTSELX_AD_OUT1_TO_SLOT_ODD 0x00 360 - #define AB8500_ADSLOTSELX_AD_OUT2_TO_SLOT_ODD 0x10 361 - #define AB8500_ADSLOTSELX_AD_OUT3_TO_SLOT_ODD 0x20 362 - #define AB8500_ADSLOTSELX_AD_OUT4_TO_SLOT_ODD 0x30 363 - #define AB8500_ADSLOTSELX_AD_OUT5_TO_SLOT_ODD 0x40 364 - #define AB8500_ADSLOTSELX_AD_OUT6_TO_SLOT_ODD 0x50 365 - #define AB8500_ADSLOTSELX_AD_OUT7_TO_SLOT_ODD 0x60 366 - #define AB8500_ADSLOTSELX_AD_OUT8_TO_SLOT_ODD 0x70 367 - #define AB8500_ADSLOTSELX_ZEROES_TO_SLOT_ODD 0x80 368 - #define AB8500_ADSLOTSELX_TRISTATE_TO_SLOT_ODD 0xF0 369 - #define AB8500_ADSLOTSELX_AD_OUT1_TO_SLOT_EVEN 0x00 370 - #define AB8500_ADSLOTSELX_AD_OUT2_TO_SLOT_EVEN 0x01 371 - #define AB8500_ADSLOTSELX_AD_OUT3_TO_SLOT_EVEN 0x02 372 - #define AB8500_ADSLOTSELX_AD_OUT4_TO_SLOT_EVEN 0x03 373 - #define AB8500_ADSLOTSELX_AD_OUT5_TO_SLOT_EVEN 0x04 374 - #define AB8500_ADSLOTSELX_AD_OUT6_TO_SLOT_EVEN 0x05 375 - #define AB8500_ADSLOTSELX_AD_OUT7_TO_SLOT_EVEN 0x06 376 - #define AB8500_ADSLOTSELX_AD_OUT8_TO_SLOT_EVEN 0x07 377 - #define AB8500_ADSLOTSELX_ZEROES_TO_SLOT_EVEN 0x08 378 - #define AB8500_ADSLOTSELX_TRISTATE_TO_SLOT_EVEN 0x0F 357 + #define AB8500_AD_OUT1 0x0 358 + #define AB8500_AD_OUT2 0x1 359 + #define AB8500_AD_OUT3 0x2 360 + #define AB8500_AD_OUT4 0x3 361 + #define AB8500_AD_OUT5 0x4 362 + #define AB8500_AD_OUT6 0x5 363 + #define AB8500_AD_OUT7 0x6 364 + #define AB8500_AD_OUT8 0x7 365 + #define AB8500_ZEROES 0x8 366 + #define AB8500_TRISTATE 0xF 379 367 #define AB8500_ADSLOTSELX_EVEN_SHIFT 0 380 368 #define AB8500_ADSLOTSELX_ODD_SHIFT 4 369 + #define AB8500_ADSLOTSELX_AD_OUT_TO_SLOT(out, slot) \ 370 + ((out) << (((slot) & 1) ? \ 371 + AB8500_ADSLOTSELX_ODD_SHIFT : AB8500_ADSLOTSELX_EVEN_SHIFT)) 381 372 382 373 /* AB8500_ADSLOTHIZCTRL1 */ 383 374 /* AB8500_ADSLOTHIZCTRL2 */