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

Configure Feed

Select the types of activity you want to include in your feed.

ALSA: ctxfi: Add ADC helper functions for GPIO

Add helper functions hw_adc_stop(), hw_adc_start(), and hw_adc_reset()
to encapsulate ADC reset sequence operations. These functions reduce
duplication by centralizing the GPIO-based ADC control logic.

Signed-off-by: Harin Lee <me@harin.net>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20251124180501.2760421-3-me@harin.net

authored by

Harin Lee and committed by
Takashi Iwai
4b490e0d 5ebd0542

+28 -9
+28 -9
sound/pci/ctxfi/cthw20k2.c
··· 1826 1826 return 0; 1827 1827 } 1828 1828 1829 + static void hw_adc_stop(struct hw *hw) 1830 + { 1831 + u32 data; 1832 + /* Reset the ADC (reset is active low). */ 1833 + data = hw_read_20kx(hw, GPIO_DATA); 1834 + data &= ~(0x1 << 15); 1835 + hw_write_20kx(hw, GPIO_DATA, data); 1836 + usleep_range(10000, 11000); 1837 + } 1838 + 1839 + static void hw_adc_start(struct hw *hw) 1840 + { 1841 + u32 data; 1842 + /* Return the ADC to normal operation. */ 1843 + data = hw_read_20kx(hw, GPIO_DATA); 1844 + data |= (0x1 << 15); 1845 + hw_write_20kx(hw, GPIO_DATA, data); 1846 + msleep(50); 1847 + } 1848 + 1849 + static void __maybe_unused hw_adc_reset(struct hw *hw) 1850 + { 1851 + hw_adc_stop(hw); 1852 + hw_adc_start(hw); 1853 + } 1854 + 1829 1855 static int hw_adc_init(struct hw *hw, const struct adc_conf *info) 1830 1856 { 1831 1857 int err; ··· 1869 1843 goto error; 1870 1844 } 1871 1845 1872 - /* Reset the ADC (reset is active low). */ 1873 - data = hw_read_20kx(hw, GPIO_DATA); 1874 - data &= ~(0x1 << 15); 1875 - hw_write_20kx(hw, GPIO_DATA, data); 1846 + hw_adc_stop(hw); 1876 1847 1877 1848 if (hw->model == CTSB1270) { 1878 1849 /* Set up the PCM4220 ADC on Titanium HD */ ··· 1883 1860 hw_write_20kx(hw, GPIO_DATA, data); 1884 1861 } 1885 1862 1886 - usleep_range(10000, 11000); 1887 - /* Return the ADC to normal operation. */ 1888 - data |= (0x1 << 15); 1889 - hw_write_20kx(hw, GPIO_DATA, data); 1890 - msleep(50); 1863 + hw_adc_start(hw); 1891 1864 1892 1865 /* I2C write to register offset 0x0B to set ADC LRCLK polarity */ 1893 1866 /* invert bit, interface format to I2S, word length to 24-bit, */