From nobody Tue Dec 2 01:05:43 2025 Received: from sender3-op-o15.zoho.com (sender3-op-o15.zoho.com [136.143.184.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 54A852DC782; Fri, 21 Nov 2025 15:22:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.184.15 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763738566; cv=pass; b=otGL4h2wtiMQbVvAFGEfnOUI4v9ERKgFtxUaUFHW/2mrCCmGb7w4zrVpC1FuIjOqig1t+s544y/QRNFTi7biok0HeDimS5PSLHtvBk1iriXez5puge7zNrM5xtAjkiCqDPXlTWyQAu1vtSEx/dZuSBAtXkkqE9yELKzMG+tIfig= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763738566; c=relaxed/simple; bh=U5/e7P29lKlkUX4b8STHb32Dh50bg29aLAgjK7aYkI4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BQq3lQetMFLTwmlhd4Q0F+f56JaHgtSMRfZv5CGxY4XADN/xLj2tvF3SY4vjKJG99VgHbpV/vX2TW75yCE9W3qpv8Y+EZ8e7zfwQs3b9Ed5TmJ0lt1IFztclYFRPVCrdkirO6YDYSsBebebI5mxCaW2bkQdzGxvDKI8mJ6ee5kI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=harin.net; spf=pass smtp.mailfrom=harin.net; dkim=pass (2048-bit key) header.d=harin.net header.i=me@harin.net header.b=SNrJ92uN; arc=pass smtp.client-ip=136.143.184.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=harin.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=harin.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=harin.net header.i=me@harin.net header.b="SNrJ92uN" ARC-Seal: i=1; a=rsa-sha256; t=1763738554; cv=none; d=zohomail.com; s=zohoarc; b=CzbHnnrU/zqMWEWrOjxYScYn3srJB126xs4N21jj5y3GPZs50QUhJ35/zOPAzAkQ++TAcLb63IkUYOQZWuY39TamTdOu0kIuIeTDILu3Y4dIGfOm5xc66iF8wDp3fAWjbSUt2e577MVi9YeIEUlmDXIzBXuLT5Bep77rPWEdJD8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1763738554; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=Pc8fYETImu86tY789NAksTljrtHo8+Ce0lBVCcBIvrI=; b=WH7TajFgo+HfxEzH8IBSUeILtE77crLIVbIecR8lCVnL0/TuJVG4Bv6iHxPy6nwoWGOZE8yXE6ABrgNu2AogPT8dOYpCi1PZwdRrkX35D4z/EsWen+6i9g3z0dEsfsZx3lONUhAVNt/4q4D65muXCtP3mxbyBpQbynf8siMyvCQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=harin.net; spf=pass smtp.mailfrom=me@harin.net; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1763738553; s=zmail; d=harin.net; i=me@harin.net; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To; bh=Pc8fYETImu86tY789NAksTljrtHo8+Ce0lBVCcBIvrI=; b=SNrJ92uNRPqGwHXVKGNN2SyOgUDisLgPcWxODZkIIqPDGcZPIpYaQZtn+lMNy1Sa S3PeL7PEwOIjHyurj9KGcUdZR350wMBju2Ycalgc8BLETLVMd0tx8Vdoj2hulxTg5BQ phGIh99vyqMSOuL1YIFi9NtpP42ZKMBa9HhCZtdgaI6hbxAc1oUcqJgfSJzY/fVV0qS 0OMmTYK8+5oJ4fCNmf79kxBx6EoIg/QFa5WXjus5Qsam6+3/U9PFtlKVCcdsVcrb4MW K08AI+txWXlcHfq9GPwb5Uiseg+tvroYz/11jPLNehLrBD3a5tsXNwLY8EgEltQOzAl efLQ1C4TMg== Received: by mx.zohomail.com with SMTPS id 1763738551668464.23801436422093; Fri, 21 Nov 2025 07:22:31 -0800 (PST) From: Harin Lee To: Jaroslav Kysela , Takashi Iwai Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Harin Lee Subject: [PATCH v2 1/6] ALSA: ctxfi: Add hw parameter to daio_mgr_dao_init() Date: Sat, 22 Nov 2025 00:22:15 +0900 Message-ID: <20251121152221.1152523-2-me@harin.net> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251121152221.1152523-1-me@harin.net> References: <20251121152221.1152523-1-me@harin.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" Add a hw parameter to the daio_mgr_dao_init() function to provide access to model-specific information. This is necessary for proper configuration of S/PDIF and I2S output ports on different hardware variants. Signed-off-by: Harin Lee --- sound/pci/ctxfi/ctdaio.c | 2 +- sound/pci/ctxfi/cthardware.h | 2 +- sound/pci/ctxfi/cthw20k1.c | 2 +- sound/pci/ctxfi/cthw20k2.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/pci/ctxfi/ctdaio.c b/sound/pci/ctxfi/ctdaio.c index c0c3f8ab8467..10d0a7088718 100644 --- a/sound/pci/ctxfi/ctdaio.c +++ b/sound/pci/ctxfi/ctdaio.c @@ -390,7 +390,7 @@ static int dao_rsc_init(struct dao *dao, hw->daio_mgr_commit_write(hw, mgr->mgr.ctrl_blk); =20 conf =3D (desc->msr & 0x7) | (desc->passthru << 3); - hw->daio_mgr_dao_init(mgr->mgr.ctrl_blk, + hw->daio_mgr_dao_init(hw, mgr->mgr.ctrl_blk, daio_device_index(dao->daio.type, hw), conf); hw->daio_mgr_enb_dao(mgr->mgr.ctrl_blk, daio_device_index(dao->daio.type, hw)); diff --git a/sound/pci/ctxfi/cthardware.h b/sound/pci/ctxfi/cthardware.h index 2875cec83b8f..d29b4e5b3fcc 100644 --- a/sound/pci/ctxfi/cthardware.h +++ b/sound/pci/ctxfi/cthardware.h @@ -167,7 +167,7 @@ struct hw { int (*daio_mgr_dsb_dai)(void *blk, unsigned int idx); int (*daio_mgr_enb_dao)(void *blk, unsigned int idx); int (*daio_mgr_dsb_dao)(void *blk, unsigned int idx); - int (*daio_mgr_dao_init)(void *blk, unsigned int idx, + int (*daio_mgr_dao_init)(struct hw *hw, void *blk, unsigned int idx, unsigned int conf); int (*daio_mgr_set_imaparc)(void *blk, unsigned int slot); int (*daio_mgr_set_imapnxt)(void *blk, unsigned int next); diff --git a/sound/pci/ctxfi/cthw20k1.c b/sound/pci/ctxfi/cthw20k1.c index 42b90c9b2ee9..60cc1d14453a 100644 --- a/sound/pci/ctxfi/cthw20k1.c +++ b/sound/pci/ctxfi/cthw20k1.c @@ -1031,7 +1031,7 @@ static int daio_mgr_dsb_dao(void *blk, unsigned int i= dx) return 0; } =20 -static int daio_mgr_dao_init(void *blk, unsigned int idx, unsigned int con= f) +static int daio_mgr_dao_init(struct hw *hw __maybe_unused, void *blk, unsi= gned int idx, unsigned int conf) { struct daio_mgr_ctrl_blk *ctl =3D blk; =20 diff --git a/sound/pci/ctxfi/cthw20k2.c b/sound/pci/ctxfi/cthw20k2.c index 55af8ef29838..1a085e7e5786 100644 --- a/sound/pci/ctxfi/cthw20k2.c +++ b/sound/pci/ctxfi/cthw20k2.c @@ -985,7 +985,7 @@ static int daio_mgr_dsb_dao(void *blk, unsigned int idx) return 0; } =20 -static int daio_mgr_dao_init(void *blk, unsigned int idx, unsigned int con= f) +static int daio_mgr_dao_init(struct hw *hw __maybe_unused, void *blk, unsi= gned int idx, unsigned int conf) { struct daio_mgr_ctrl_blk *ctl =3D blk; =20 --=20 2.52.0 From nobody Tue Dec 2 01:05:43 2025 Received: from sender3-op-o15.zoho.com (sender3-op-o15.zoho.com [136.143.184.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A29852D8399; Fri, 21 Nov 2025 15:22:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.184.15 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763738567; cv=pass; b=It3yMhWEPIvPUfjRRPKuxHvQPbjR+x97lKZzj2BipJxemyZeo1q7sYRwvGJAFP0juQ48NE3aL4v6M+aO66QHnxtYDzYsjSJN05NYPqsGXSXWr1S396gCGJxEBmVGgH+2OBQeyDx9SllRh3mC+PYK4tcO6y9QcBFPX27hBE0aYLk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763738567; c=relaxed/simple; bh=4hN2+mR9RXFyMchseG+eh5R/NumPRLG/RBqLbk3clVc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Oq9ewR0o4Z97v8nKddyIWFM4RHmaN1ak/r/icgaKuxHWLrIsXjPn9BG14oPw95j69Lt3/IWj3YtMstSkvEzx9Gyo414mAsFHycKTRrU0s70rN18yu/698eBbA2KU/imc7JTTj9T0QGKG2AprK1ZsYYwGF3erFezCIoYg3pyIKls= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=harin.net; spf=pass smtp.mailfrom=harin.net; dkim=pass (2048-bit key) header.d=harin.net header.i=me@harin.net header.b=CninAw/V; arc=pass smtp.client-ip=136.143.184.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=harin.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=harin.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=harin.net header.i=me@harin.net header.b="CninAw/V" ARC-Seal: i=1; a=rsa-sha256; t=1763738556; cv=none; d=zohomail.com; s=zohoarc; b=iBKMFyk3Cg2HcaH6XPiiixhAKHEVo5UYKiTJ5E/icOO22aCXjduapnDQwJ81gwTcMZbBEYH4ZOQMODe8TA0h4cAMugw6EKuVE6/9WlByPdPn4xZCtbANAo0jHlQxp9fNK6b0JXnDSHF7shEQsWAKUjxkzcAdgkozvufRj9/OuzU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1763738556; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=lP+2wIUwkdEoZx7g500+cPO+PZdEE2LTFPtL4FjU9JE=; b=W8Ipa8woLEX+Ph7+kVyLzSp8xU8UlmFPM4K9xPkesTAYiRukPZMdFcN2lWz1npiSK1X9pQRLRAG7TqMQawH6EruZtcFhXYcFn6BWavX6Mewa64qLNreD8L5SC7qeQaYUff2mwuVykJsA4W58aTMbZaD/W4YD5fN/F6oh3N5VCSk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=harin.net; spf=pass smtp.mailfrom=me@harin.net; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1763738555; s=zmail; d=harin.net; i=me@harin.net; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To; bh=lP+2wIUwkdEoZx7g500+cPO+PZdEE2LTFPtL4FjU9JE=; b=CninAw/VG8PbDwrvOc0G4IwAvupTSLX4su3zsELSytxeOtH34r9yQQiEeuhzjoHu eIbrhL6g3xpYwbemVVNhPhm4AHHP+eTixTG8voAXSwg+BSuRnS/3aATJO5bUOBSEUQV L4Bx0qOfYcSem6L2NFsv3hJMeVREkpRdqQIo8uHt4TOYzKP3Cll8UBUUUzMTKaCyR2f Du0ZuuXgBbmv7SIwGxFpnwcoX/9czfm5Ze3IAK40Gy3GjEdK1bvnVmYWRMTCWZbXpRQ 7PniDpeMun/wJ3PFCjTExN8lLFsGv6WOPV7HGk/Ib0wE5a7lpvQ+gU9ravgN+JhtBBY bd2gP4rAGg== Received: by mx.zohomail.com with SMTPS id 1763738553488366.22871214662166; Fri, 21 Nov 2025 07:22:33 -0800 (PST) From: Harin Lee To: Jaroslav Kysela , Takashi Iwai Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Harin Lee Subject: [PATCH v2 2/6] ALSA: ctxfi: Add ADC helper functions for GPIO Date: Sat, 22 Nov 2025 00:22:16 +0900 Message-ID: <20251121152221.1152523-3-me@harin.net> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251121152221.1152523-1-me@harin.net> References: <20251121152221.1152523-1-me@harin.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" 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 --- sound/pci/ctxfi/cthw20k2.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/sound/pci/ctxfi/cthw20k2.c b/sound/pci/ctxfi/cthw20k2.c index 1a085e7e5786..5d39bc943648 100644 --- a/sound/pci/ctxfi/cthw20k2.c +++ b/sound/pci/ctxfi/cthw20k2.c @@ -1826,6 +1826,32 @@ static int hw_adc_input_select(struct hw *hw, enum A= DCSRC type) return 0; } =20 +static void hw_adc_stop(struct hw *hw) +{ + u32 data; + /* Reset the ADC (reset is active low). */ + data =3D hw_read_20kx(hw, GPIO_DATA); + data &=3D ~(0x1 << 15); + hw_write_20kx(hw, GPIO_DATA, data); + usleep_range(10000, 11000); +} + +static void hw_adc_start(struct hw *hw) +{ + u32 data; + /* Return the ADC to normal operation. */ + data =3D hw_read_20kx(hw, GPIO_DATA); + data |=3D (0x1 << 15); + hw_write_20kx(hw, GPIO_DATA, data); + msleep(50); +} + +static void __maybe_unused hw_adc_reset(struct hw *hw) +{ + hw_adc_stop(hw); + hw_adc_start(hw); +} + static int hw_adc_init(struct hw *hw, const struct adc_conf *info) { int err; @@ -1843,10 +1869,7 @@ static int hw_adc_init(struct hw *hw, const struct a= dc_conf *info) goto error; } =20 - /* Reset the ADC (reset is active low). */ - data =3D hw_read_20kx(hw, GPIO_DATA); - data &=3D ~(0x1 << 15); - hw_write_20kx(hw, GPIO_DATA, data); + hw_adc_stop(hw); =20 if (hw->model =3D=3D CTSB1270) { /* Set up the PCM4220 ADC on Titanium HD */ @@ -1860,11 +1883,7 @@ static int hw_adc_init(struct hw *hw, const struct a= dc_conf *info) hw_write_20kx(hw, GPIO_DATA, data); } =20 - usleep_range(10000, 11000); - /* Return the ADC to normal operation. */ - data |=3D (0x1 << 15); - hw_write_20kx(hw, GPIO_DATA, data); - msleep(50); + hw_adc_start(hw); =20 /* I2C write to register offset 0x0B to set ADC LRCLK polarity */ /* invert bit, interface format to I2S, word length to 24-bit, */ --=20 2.52.0 From nobody Tue Dec 2 01:05:43 2025 Received: from sender3-op-o12.zoho.com (sender3-op-o12.zoho.com [136.143.184.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C3A22F8BD0; Fri, 21 Nov 2025 15:22:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.184.12 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763738567; cv=pass; b=YpdsBn9XpyXPKw+xP+9iO1D8eOv8n1JhgyqS4eM2Gh/FuoW9H2Mq43slUnLxD3ZSXHKDFAC9BXJtt7jyiFOE0iKnHDRT7b69O07xx6469C8qLz7QxfFU++CvE+ieq5eMRvb2VrZgEzi2eOZGddvITBB5OsACoN8QYTYSPiweouE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763738567; c=relaxed/simple; bh=cvE0gK8GFyqHqeLS9tlgg3O+qTSh0GGhikJbWq2UmsU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N2OqYZmgm+5HZ0eg0BgLEU1wqKn9wZ233eGriGAvamK/DFJTb/Gvi9dCp1y7aUOmBDWXqsPi2BWUuG67lGS18mj635XBUA2VD9rfS3PQBz5Dd9XWIRH7Rp/8zN7TC3YoXTdpAppTTbV+W+FIjCD7EGA6GzZVska4N6j5EQvQUHE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=harin.net; spf=pass smtp.mailfrom=harin.net; dkim=pass (2048-bit key) header.d=harin.net header.i=me@harin.net header.b=PhFTGklI; arc=pass smtp.client-ip=136.143.184.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=harin.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=harin.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=harin.net header.i=me@harin.net header.b="PhFTGklI" ARC-Seal: i=1; a=rsa-sha256; t=1763738557; cv=none; d=zohomail.com; s=zohoarc; b=kOg5m+Raii5TRTiyHihI2FDYzT4nrD84BRZLXpBSfZ2gPMLOYb7d0j6XjDWWv5unuT9V5I8CsXaLwVtTRmWoXPoOdyIDYllgY7Bu7yN1eympH0+D9uEX+auV2J2oJQF6C+nDVH4AYFCTwhjOayoVstPY1M8VRJXi1ct4mYASu08= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1763738557; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=R2sMbLrTwMVsiTBJtqP3HgefDwrj/DVNSppBJ+oYTjA=; b=VluQrb9r4h+TLQm9rvjlOLwlJr/F+MlsINccupKO+qRLjKb5/Aa7hUMw53VJKKR6+gacv2veyB639mz9cGr3ORHKXDvCHvUGdQoBmXuIfhLakQ555CuEfMo6y32gl9x5KKxVxP+4/keho7SqO3FhG0NKr8PzJXTQMqzhBLLsDP4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=harin.net; spf=pass smtp.mailfrom=me@harin.net; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1763738557; s=zmail; d=harin.net; i=me@harin.net; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To; bh=R2sMbLrTwMVsiTBJtqP3HgefDwrj/DVNSppBJ+oYTjA=; b=PhFTGklIGNjXgxWWbNPN3vISuZpTH58AGF88bYcWdnumBArff+GX7767BMvXb4vZ NjI3z3Uyc1mMjgRpX7USTV3MxmzezEJveCahEFvNeXLkQ7Q9VKoRa2/PUwNSM0lt7rn vdAOG6eygfvuf1UMY4MAufRH8cAwtp8Lid1Exlcrltvr8rHxuS8QKSyW6a+WfHgMMVb +sl8oJXDSeP360EwxEYnLSQ4txQV5xAJinuVAcm77Dt4AO5HS5nNfgSC732fwOKhNSd 9NWtee/CGp2/i1PgfJ8PpIccZGj0JEURNwpfR9cuYbTVCDP6G9aP59sC+KuXjnDvCKB Ovy7JaUglQ== Received: by mx.zohomail.com with SMTPS id 1763738555313597.7338823904468; Fri, 21 Nov 2025 07:22:35 -0800 (PST) From: Harin Lee To: Jaroslav Kysela , Takashi Iwai Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Harin Lee Subject: [PATCH v2 3/6] ALSA: ctxfi: Use explicit output flag for DAIO resources Date: Sat, 22 Nov 2025 00:22:17 +0900 Message-ID: <20251121152221.1152523-4-me@harin.net> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251121152221.1152523-1-me@harin.net> References: <20251121152221.1152523-1-me@harin.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" Replace the index-based type check with an explicit output flag in struct daio and struct daio_desc. This allows handling DAIO resource types correctly regardless of their index. This is necessary for hardware variants where resource types do not follow a sequential order. Signed-off-by: Harin Lee --- sound/pci/ctxfi/ctatc.c | 3 ++- sound/pci/ctxfi/ctdaio.c | 14 +++++++------- sound/pci/ctxfi/ctdaio.h | 2 ++ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/sound/pci/ctxfi/ctatc.c b/sound/pci/ctxfi/ctatc.c index 14779b383d9e..4719310d0daf 100644 --- a/sound/pci/ctxfi/ctatc.c +++ b/sound/pci/ctxfi/ctatc.c @@ -1163,7 +1163,7 @@ static int atc_release_resources(struct ct_atc *atc) daio_mgr =3D (struct daio_mgr *)atc->rsc_mgrs[DAIO]; for (i =3D 0; i < atc->n_daio; i++) { daio =3D atc->daios[i]; - if (daio->type < LINEIM) { + if (daio->output) { dao =3D container_of(daio, struct dao, daio); dao->ops->clear_left_input(dao); dao->ops->clear_right_input(dao); @@ -1393,6 +1393,7 @@ static int atc_get_resources(struct ct_atc *atc) for (i =3D 0, atc->n_daio =3D 0; i < num_daios; i++) { da_desc.type =3D (atc->model !=3D CTSB073X) ? i : ((i =3D=3D SPDIFIO) ? SPDIFI1 : i); + da_desc.output =3D (i < LINEIM); err =3D daio_mgr->get_daio(daio_mgr, &da_desc, (struct daio **)&atc->daios[i]); if (err) { diff --git a/sound/pci/ctxfi/ctdaio.c b/sound/pci/ctxfi/ctdaio.c index 10d0a7088718..f012d47689d1 100644 --- a/sound/pci/ctxfi/ctdaio.c +++ b/sound/pci/ctxfi/ctdaio.c @@ -18,8 +18,6 @@ #include #include =20 -#define DAIO_OUT_MAX SPDIFOO - struct daio_usage { unsigned short data; }; @@ -329,7 +327,7 @@ static int daio_rsc_init(struct daio *daio, goto error1; =20 /* Set daio->rscl/r->ops to daio specific ones */ - if (desc->type <=3D DAIO_OUT_MAX) { + if (desc->output) { daio->rscl.ops =3D daio->rscr.ops =3D &daio_out_rsc_ops; } else { switch (hw->chip_type) { @@ -344,6 +342,7 @@ static int daio_rsc_init(struct daio *daio, } } daio->type =3D desc->type; + daio->output =3D desc->output; =20 return 0; =20 @@ -433,6 +432,7 @@ static int dao_rsc_reinit(struct dao *dao, const struct= dao_desc *desc) dsc.type =3D dao->daio.type; dsc.msr =3D desc->msr; dsc.passthru =3D desc->passthru; + dsc.output =3D dao->daio.output; dao_rsc_uninit(dao); return dao_rsc_init(dao, &dsc, mgr); } @@ -518,7 +518,7 @@ static int get_daio_rsc(struct daio_mgr *mgr, =20 err =3D -ENOMEM; /* Allocate mem for daio resource */ - if (desc->type <=3D DAIO_OUT_MAX) { + if (desc->output) { struct dao *dao =3D kzalloc(sizeof(*dao), GFP_KERNEL); if (!dao) goto error; @@ -565,7 +565,7 @@ static int put_daio_rsc(struct daio_mgr *mgr, struct da= io *daio) daio_mgr_put_rsc(&mgr->mgr, daio->type); } =20 - if (daio->type <=3D DAIO_OUT_MAX) { + if (daio->output) { dao_rsc_uninit(container_of(daio, struct dao, daio)); kfree(container_of(daio, struct dao, daio)); } else { @@ -580,7 +580,7 @@ static int daio_mgr_enb_daio(struct daio_mgr *mgr, stru= ct daio *daio) { struct hw *hw =3D mgr->mgr.hw; =20 - if (DAIO_OUT_MAX >=3D daio->type) { + if (daio->output) { hw->daio_mgr_enb_dao(mgr->mgr.ctrl_blk, daio_device_index(daio->type, hw)); } else { @@ -594,7 +594,7 @@ static int daio_mgr_dsb_daio(struct daio_mgr *mgr, stru= ct daio *daio) { struct hw *hw =3D mgr->mgr.hw; =20 - if (DAIO_OUT_MAX >=3D daio->type) { + if (daio->output) { hw->daio_mgr_dsb_dao(mgr->mgr.ctrl_blk, daio_device_index(daio->type, hw)); } else { diff --git a/sound/pci/ctxfi/ctdaio.h b/sound/pci/ctxfi/ctdaio.h index 15147fe5f74a..b337da2de8b5 100644 --- a/sound/pci/ctxfi/ctdaio.h +++ b/sound/pci/ctxfi/ctdaio.h @@ -43,6 +43,7 @@ struct daio { struct rsc rscl; /* Basic resource info for left TX/RX */ struct rsc rscr; /* Basic resource info for right TX/RX */ enum DAIOTYP type; + unsigned char output; }; =20 struct dao { @@ -91,6 +92,7 @@ struct daio_desc { unsigned int type:4; unsigned int msr:4; unsigned int passthru:1; + unsigned int output:1; }; =20 struct daio_mgr { --=20 2.52.0 From nobody Tue Dec 2 01:05:43 2025 Received: from sender3-op-o12.zoho.com (sender3-op-o12.zoho.com [136.143.184.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE526346E54; Fri, 21 Nov 2025 15:22:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.184.12 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763738570; cv=pass; b=d/KI+tWhckXgXZ3BYEMk+myyBY7K6oZ4tpwoqdvUvuc6910qqwC6eaLeVLPBXS8nVsI/+yPr4PhrQy0PMYMNfWwnzmP5JYfbuN5xi8bMK3vMQId4WnDFiW1+WDIAgJPGiOfupFK6zYg0q1xB/KkL8l5Rk5h/wNMfn68FY+Dy8e4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763738570; c=relaxed/simple; bh=B1Uo4I+QMS2g33FRhhK409zvkqFzSWhgJjuH6mF2MVg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VYWnt3Lcr9m80PiXq3Bi4G3oHzOzXuVh7GGmU7E7OOCg0NEB05RZS9y4ISR27rs9uslfICoarLvo+XDO1iwL1PDjpX0fK/ywbVsGn/Vc61AXocBiW1yBbiPIoXJGqQJr9NdBQQ/YUF84xfwzaKgfESgEi6Nrl9H+iSDM+9A6ieA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=harin.net; spf=pass smtp.mailfrom=harin.net; dkim=pass (2048-bit key) header.d=harin.net header.i=me@harin.net header.b=IiJ3+L3P; arc=pass smtp.client-ip=136.143.184.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=harin.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=harin.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=harin.net header.i=me@harin.net header.b="IiJ3+L3P" ARC-Seal: i=1; a=rsa-sha256; t=1763738559; cv=none; d=zohomail.com; s=zohoarc; b=lswe+6TudVghEhUsEadkhD7Qi86O+MktOKU51jt1l9tWAxs/+2wGMdc8uc7VSdxXlrsUqQbW0rc5sgzTwGkBCEgoyUPh91kOexHUxoGUg0QcT/p0fvQ4YktJhkHw4FrdBZlubr7YuJSgEUCh8O4Np//iyTJW6W14vsesIu/zvZ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1763738559; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=RtX3EPlwaF//L//oMs05r3TbF5sHKvoqV1lkf6z5Rm4=; b=gWEiQaXsi3XefRGYXR48kHoVLkyB5k3HpMi4Xv9+HJXvFbj2zkOPg7T2sJmdblEst75TZUXuTYlbJu+I+QcYrM2k1qd0eCiGkms77dZypW2k2E2EqjG1iJeZ9ApIMqvPuBmAKil5NnMTifNfLwwJ6sd7KEAXcq7IISXRW0vGFQI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=harin.net; spf=pass smtp.mailfrom=me@harin.net; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1763738559; s=zmail; d=harin.net; i=me@harin.net; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To; bh=RtX3EPlwaF//L//oMs05r3TbF5sHKvoqV1lkf6z5Rm4=; b=IiJ3+L3PCJ4Fm5WNIw3KYnFTGrCodvi6hypEEwNr/DKPdZMUKN1qNQpb3yXPcmXd wwV4YVeITZsgoHV3RNk36waHpOHbvT2POJkB0jPP6fVclZBqWblLr61tci1hXVAl8wJ DavHJgIRxfSczzLfWJiw5jmlOr9wkZaw6dWiDFRuV65vTTTHrjWY+Y833uVG0Om5DC0 U1cwSiGU621gVk2hRq6/HXF3HBqEnXAErgQnzaWAd7w9pj5JPGJzxoZztccIIQdVZFe T0GiU7khXQ40Mr4NdqPEQIjIC38PRU9hWHbic7tip2yTRiTRp5lou5GUzhgzRaHxiM8 vRE5utCUfQ== Received: by mx.zohomail.com with SMTPS id 1763738557133149.28467807412017; Fri, 21 Nov 2025 07:22:37 -0800 (PST) From: Harin Lee To: Jaroslav Kysela , Takashi Iwai Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Harin Lee Subject: [PATCH v2 4/6] ALSA: ctxfi: Refactor resource alloc for sparse mappings Date: Sat, 22 Nov 2025 00:22:18 +0900 Message-ID: <20251121152221.1152523-5-me@harin.net> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251121152221.1152523-1-me@harin.net> References: <20251121152221.1152523-1-me@harin.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" Refactor atc_get_resources(), atc_connect_resources(), and atc_release_resources() to allocate resources based on maximum type definitions. This allows specific resources to be conditionally skipped based on capabilities. This is necessary for hardware variants where resource allocations do not follow a sequential order. Signed-off-by: Harin Lee --- sound/pci/ctxfi/ctatc.c | 60 ++++++++++++++++++++++++----------------- sound/pci/ctxfi/ctatc.h | 4 --- 2 files changed, 35 insertions(+), 29 deletions(-) diff --git a/sound/pci/ctxfi/ctatc.c b/sound/pci/ctxfi/ctatc.c index 4719310d0daf..80888fffebd1 100644 --- a/sound/pci/ctxfi/ctatc.c +++ b/sound/pci/ctxfi/ctatc.c @@ -25,6 +25,9 @@ #include #include =20 +#define NUM_ATC_SRCS 6 +#define NUM_ATC_PCM (2 * 4) + #define MONO_SUM_SCALE 0x19a8 /* 2^(-0.5) in 14-bit floating format */ #define MAX_MULTI_CHN 8 =20 @@ -1161,8 +1164,10 @@ static int atc_release_resources(struct ct_atc *atc) =20 if (atc->daios) { daio_mgr =3D (struct daio_mgr *)atc->rsc_mgrs[DAIO]; - for (i =3D 0; i < atc->n_daio; i++) { + for (i =3D 0; i < NUM_DAIOTYP; i++) { daio =3D atc->daios[i]; + if (!daio) + continue; if (daio->output) { dao =3D container_of(daio, struct dao, daio); dao->ops->clear_left_input(dao); @@ -1176,8 +1181,9 @@ static int atc_release_resources(struct ct_atc *atc) =20 if (atc->pcm) { sum_mgr =3D atc->rsc_mgrs[SUM]; - for (i =3D 0; i < atc->n_pcm; i++) - sum_mgr->put_sum(sum_mgr, atc->pcm[i]); + for (i =3D 0; i < NUM_ATC_PCM; i++) + if (atc->pcm[i]) + sum_mgr->put_sum(sum_mgr, atc->pcm[i]); =20 kfree(atc->pcm); atc->pcm =3D NULL; @@ -1185,8 +1191,9 @@ static int atc_release_resources(struct ct_atc *atc) =20 if (atc->srcs) { src_mgr =3D atc->rsc_mgrs[SRC]; - for (i =3D 0; i < atc->n_src; i++) - src_mgr->put_src(src_mgr, atc->srcs[i]); + for (i =3D 0; i < NUM_ATC_SRCS; i++) + if (atc->srcs[i]) + src_mgr->put_src(src_mgr, atc->srcs[i]); =20 kfree(atc->srcs); atc->srcs =3D NULL; @@ -1194,7 +1201,9 @@ static int atc_release_resources(struct ct_atc *atc) =20 if (atc->srcimps) { srcimp_mgr =3D atc->rsc_mgrs[SRCIMP]; - for (i =3D 0; i < atc->n_srcimp; i++) { + for (i =3D 0; i < NUM_ATC_SRCS; i++) { + if (!atc->srcimps[i]) + continue; srcimp =3D atc->srcimps[i]; srcimp->ops->unmap(srcimp); srcimp_mgr->put_srcimp(srcimp_mgr, atc->srcimps[i]); @@ -1367,30 +1376,32 @@ static int atc_get_resources(struct ct_atc *atc) struct srcimp_mgr *srcimp_mgr; struct sum_desc sum_dsc =3D {0}; struct sum_mgr *sum_mgr; - int err, i, num_srcs, num_daios; + struct capabilities cap; + int err, i; =20 - num_daios =3D ((atc->model =3D=3D CTSB1270) ? 8 : 7); - num_srcs =3D ((atc->model =3D=3D CTSB1270) ? 6 : 4); + cap =3D atc->capabilities(atc); =20 - atc->daios =3D kcalloc(num_daios, sizeof(void *), GFP_KERNEL); + atc->daios =3D kcalloc(NUM_DAIOTYP, sizeof(void *), GFP_KERNEL); if (!atc->daios) return -ENOMEM; =20 - atc->srcs =3D kcalloc(num_srcs, sizeof(void *), GFP_KERNEL); + atc->srcs =3D kcalloc(NUM_ATC_SRCS, sizeof(void *), GFP_KERNEL); if (!atc->srcs) return -ENOMEM; =20 - atc->srcimps =3D kcalloc(num_srcs, sizeof(void *), GFP_KERNEL); + atc->srcimps =3D kcalloc(NUM_ATC_SRCS, sizeof(void *), GFP_KERNEL); if (!atc->srcimps) return -ENOMEM; =20 - atc->pcm =3D kcalloc(2 * 4, sizeof(void *), GFP_KERNEL); + atc->pcm =3D kcalloc(NUM_ATC_PCM, sizeof(void *), GFP_KERNEL); if (!atc->pcm) return -ENOMEM; =20 daio_mgr =3D (struct daio_mgr *)atc->rsc_mgrs[DAIO]; da_desc.msr =3D atc->msr; - for (i =3D 0, atc->n_daio =3D 0; i < num_daios; i++) { + for (i =3D 0; i < NUM_DAIOTYP; i++) { + if ((i =3D=3D MIC) && !cap.dedicated_mic) + continue; da_desc.type =3D (atc->model !=3D CTSB073X) ? i : ((i =3D=3D SPDIFIO) ? SPDIFI1 : i); da_desc.output =3D (i < LINEIM); @@ -1402,42 +1413,39 @@ static int atc_get_resources(struct ct_atc *atc) i); return err; } - atc->n_daio++; } =20 src_mgr =3D atc->rsc_mgrs[SRC]; src_dsc.multi =3D 1; src_dsc.msr =3D atc->msr; src_dsc.mode =3D ARCRW; - for (i =3D 0, atc->n_src =3D 0; i < num_srcs; i++) { + for (i =3D 0; i < NUM_ATC_SRCS; i++) { + if (((i > 3) && !cap.dedicated_mic)) + continue; err =3D src_mgr->get_src(src_mgr, &src_dsc, (struct src **)&atc->srcs[i]); if (err) return err; - - atc->n_src++; } =20 srcimp_mgr =3D atc->rsc_mgrs[SRCIMP]; srcimp_dsc.msr =3D 8; - for (i =3D 0, atc->n_srcimp =3D 0; i < num_srcs; i++) { + for (i =3D 0; i < NUM_ATC_SRCS; i++) { + if (((i > 3) && !cap.dedicated_mic)) + continue; err =3D srcimp_mgr->get_srcimp(srcimp_mgr, &srcimp_dsc, (struct srcimp **)&atc->srcimps[i]); if (err) return err; - - atc->n_srcimp++; } =20 sum_mgr =3D atc->rsc_mgrs[SUM]; sum_dsc.msr =3D atc->msr; - for (i =3D 0, atc->n_pcm =3D 0; i < (2*4); i++) { + for (i =3D 0; i < NUM_ATC_PCM; i++) { err =3D sum_mgr->get_sum(sum_mgr, &sum_dsc, (struct sum **)&atc->pcm[i]); if (err) return err; - - atc->n_pcm++; } =20 return 0; @@ -1490,9 +1498,11 @@ static void atc_connect_resources(struct ct_atc *atc) struct sum *sum; struct ct_mixer *mixer; struct rsc *rscs[2] =3D {NULL}; + struct capabilities cap; int i, j; =20 mixer =3D atc->mixer; + cap =3D atc->capabilities(atc); =20 for (i =3D MIX_WAVE_FRONT, j =3D LINEO1; i <=3D MIX_SPDIF_OUT; i++, j++) { mixer->get_output_ports(mixer, i, &rscs[0], &rscs[1]); @@ -1510,7 +1520,7 @@ static void atc_connect_resources(struct ct_atc *atc) src =3D atc->srcs[3]; mixer->set_input_right(mixer, MIX_LINE_IN, &src->rsc); =20 - if (atc->model =3D=3D CTSB1270) { + if (cap.dedicated_mic) { /* Titanium HD has a dedicated ADC for the Mic. */ dai =3D container_of(atc->daios[MIC], struct dai, daio); atc_connect_dai(atc->rsc_mgrs[SRC], dai, diff --git a/sound/pci/ctxfi/ctatc.h b/sound/pci/ctxfi/ctatc.h index 0bc7b71d910b..671edc46bd50 100644 --- a/sound/pci/ctxfi/ctatc.h +++ b/sound/pci/ctxfi/ctatc.h @@ -132,10 +132,6 @@ struct ct_atc { void **pcm; /* SUMs for collecting all pcm stream */ void **srcs; /* Sample Rate Converters for input signal */ void **srcimps; /* input mappers for SRCs */ - unsigned char n_daio; - unsigned char n_src; - unsigned char n_srcimp; - unsigned char n_pcm; =20 struct ct_timer *timer; =20 --=20 2.52.0 From nobody Tue Dec 2 01:05:43 2025 Received: from sender3-op-o12.zoho.com (sender3-op-o12.zoho.com [136.143.184.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6DCF633F38A; Fri, 21 Nov 2025 15:22:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.184.12 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763738572; cv=pass; b=QiF3NEjOUt2NBcq+anAWpMx6pKIR0sUXpogy9RhCaQvr6hr3BrtWQItNY0KE55KTd3Hv61fjgRgzvDtIoLVT8yjDnTrz/GKFZ+LiAe44W30T7+5sUTicDWZWx+5NlOAdGjaBp4cKYFlSJm2+M4TJENQctNQPj00zN0UJt1JtxG0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763738572; c=relaxed/simple; bh=nVH+FO2vNQx5mByaCWWGD60Vk1aE7g/A0k5U4DXBLpc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y6B25fg7UlG9WMDkiWF7QyPmzcJWLqao/cKUfA5sepYM1muhVPKUKF3Cg023UIjWARQ+gwS7gM7ultgNaV3LvUQfARTc3JBC62F4H4GvUJ3nEV6Kxqwf2EwqR7yvs/j/z2g36bRJBTvMN4lyLnCUhZrM0ZZV+rYXZQ6rx5GKyA8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=harin.net; spf=pass smtp.mailfrom=harin.net; dkim=pass (2048-bit key) header.d=harin.net header.i=me@harin.net header.b=MWutsMG5; arc=pass smtp.client-ip=136.143.184.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=harin.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=harin.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=harin.net header.i=me@harin.net header.b="MWutsMG5" ARC-Seal: i=1; a=rsa-sha256; t=1763738561; cv=none; d=zohomail.com; s=zohoarc; b=dCifN4ygUsr9JjLJgySBS+4GfghqGjV37opi5P07laQ8stC3yyur5syvF/ZTodN8H91orYrd6sfywxZhv381ZTAJ5QsT4ysuBAVdGEpza7jZRKk5EMdlu7eBQEzzEE0/W6cnWa9AU6wLYAW0zef5mumMv1Boh0ANkuVXvJFU2lg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1763738561; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=Bd6i168ycPJtxyRG2NJnyByZu+xUp9p9I+TPXIOqogk=; b=XRI8Vbq7rEMP8yOKRWNp0qL3D/Wj7kxuGpyIumLEiGfMU8CJe77u04Q0QPP8T9yLpPX9/Sx39mndO04TplzD01ZHLR46bURjVKm7+MWo4hJdzYo6ZYREns9GtFKgka4+tTKLzHRckt5GK8M40S/rAfTqJsK4usZWH2lXHzEqMC8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=harin.net; spf=pass smtp.mailfrom=me@harin.net; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1763738561; s=zmail; d=harin.net; i=me@harin.net; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To; bh=Bd6i168ycPJtxyRG2NJnyByZu+xUp9p9I+TPXIOqogk=; b=MWutsMG5zXbJdiTCkKl1oPdMU03bPxQUz7N/4ze4xH+iS1ctt3HsbUZ53a0WDuS9 3XyUNDG2b11rL+K4ol7Ug11W7Pj52ZU6Ie6wTxnv9O7e6NCX7gEDuKLAZhII0aooqCI jyXKH7WzwpKIWUe8pFw+BQdXzV6Y/TRSDpCsalSSXitzD5n7u/H4F8thFk1wGLkVfYV 5vWpTiiDgBnQJiMhEO4mI7NCRUOcR7iDgshpKsV51GY8S0/IOtOSCAJiM3IHsQUcM3L u4UHikZ0U4J0pcTom+/788KH/MXzTO/DXO0dk9v0uLEV5y+a89mx88l7B33eJ36J0zD w+BUhO5dRw== Received: by mx.zohomail.com with SMTPS id 1763738558963949.1461819276633; Fri, 21 Nov 2025 07:22:38 -0800 (PST) From: Harin Lee To: Jaroslav Kysela , Takashi Iwai Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Harin Lee Subject: [PATCH v2 5/6] ALSA: ctxfi: Add support for dedicated RCA switching Date: Sat, 22 Nov 2025 00:22:19 +0900 Message-ID: <20251121152221.1152523-6-me@harin.net> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251121152221.1152523-1-me@harin.net> References: <20251121152221.1152523-1-me@harin.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" Add feature to support switching between the dedicated RCA output and the 7.1ch Front output. This is required for hardware that utilizes separate DAC circuits for RCA and 7.1ch channels. Changes: - Add dedicated_rca capability flag - Add 'Dedicated Selection Playback Enum' mixer control - Implement logic to swap DAO inputs between RCA and Front ports Signed-off-by: Harin Lee --- sound/pci/ctxfi/ctatc.c | 33 +++++++++++++++- sound/pci/ctxfi/ctatc.h | 4 ++ sound/pci/ctxfi/ctdaio.c | 2 + sound/pci/ctxfi/ctdaio.h | 1 + sound/pci/ctxfi/cthardware.h | 1 + sound/pci/ctxfi/cthw20k1.c | 1 + sound/pci/ctxfi/cthw20k2.c | 1 + sound/pci/ctxfi/ctmixer.c | 73 ++++++++++++++++++++++++++++++++++-- 8 files changed, 111 insertions(+), 5 deletions(-) diff --git a/sound/pci/ctxfi/ctatc.c b/sound/pci/ctxfi/ctatc.c index 80888fffebd1..69dad9ebbd8f 100644 --- a/sound/pci/ctxfi/ctatc.c +++ b/sound/pci/ctxfi/ctatc.c @@ -987,6 +987,24 @@ static struct capabilities atc_capabilities(struct ct_= atc *atc) return hw->capabilities(hw); } =20 +static void atc_dedicated_rca_select(struct ct_atc *atc) +{ + struct dao *dao; + struct ct_mixer *mixer =3D atc->mixer; + struct rsc *rscs[2] =3D {NULL}; + + dao =3D container_of(atc->daios[atc->rca_state ? RCA : LINEO1], + struct dao, daio); + dao->ops->clear_left_input(dao); + dao->ops->clear_right_input(dao); + + mixer->get_output_ports(mixer, MIX_WAVE_FRONT, &rscs[0], &rscs[1]); + dao =3D container_of(atc->daios[atc->rca_state ? LINEO1 : RCA], + struct dao, daio); + dao->ops->set_left_input(dao, rscs[0]); + dao->ops->set_right_input(dao, rscs[1]); +} + static int atc_output_switch_get(struct ct_atc *atc) { struct hw *hw =3D atc->hw; @@ -1088,6 +1106,11 @@ static int atc_mic_unmute(struct ct_atc *atc, unsign= ed char state) return atc_daio_unmute(atc, state, MIC); } =20 +static int atc_rca_unmute(struct ct_atc *atc, unsigned char state) +{ + return atc_daio_unmute(atc, state, RCA); +} + static int atc_spdif_out_unmute(struct ct_atc *atc, unsigned char state) { return atc_daio_unmute(atc, state, SPDIFOO); @@ -1303,6 +1326,7 @@ static int atc_identify_card(struct ct_atc *atc, unsi= gned int ssid) dev_info(atc->card->dev, "chip %s model %s (%04x:%04x) is found\n", atc->chip_name, atc->model_name, vendor_id, device_id); + atc->rca_state =3D 0; return 0; } =20 @@ -1400,11 +1424,11 @@ static int atc_get_resources(struct ct_atc *atc) daio_mgr =3D (struct daio_mgr *)atc->rsc_mgrs[DAIO]; da_desc.msr =3D atc->msr; for (i =3D 0; i < NUM_DAIOTYP; i++) { - if ((i =3D=3D MIC) && !cap.dedicated_mic) + if (((i =3D=3D MIC) && !cap.dedicated_mic) || ((i =3D=3D RCA) && !cap.de= dicated_rca)) continue; da_desc.type =3D (atc->model !=3D CTSB073X) ? i : ((i =3D=3D SPDIFIO) ? SPDIFI1 : i); - da_desc.output =3D (i < LINEIM); + da_desc.output =3D ((i < LINEIM) || (i =3D=3D RCA)); err =3D daio_mgr->get_daio(daio_mgr, &da_desc, (struct daio **)&atc->daios[i]); if (err) { @@ -1511,6 +1535,9 @@ static void atc_connect_resources(struct ct_atc *atc) dao->ops->set_right_input(dao, rscs[1]); } =20 + if (cap.dedicated_rca) + atc_dedicated_rca_select(atc); + dai =3D container_of(atc->daios[LINEIM], struct dai, daio); atc_connect_dai(atc->rsc_mgrs[SRC], dai, (struct src **)&atc->srcs[2], @@ -1643,12 +1670,14 @@ static const struct ct_atc atc_preset =3D { .line_rear_unmute =3D atc_line_rear_unmute, .line_in_unmute =3D atc_line_in_unmute, .mic_unmute =3D atc_mic_unmute, + .rca_unmute =3D atc_rca_unmute, .spdif_out_unmute =3D atc_spdif_out_unmute, .spdif_in_unmute =3D atc_spdif_in_unmute, .spdif_out_get_status =3D atc_spdif_out_get_status, .spdif_out_set_status =3D atc_spdif_out_set_status, .spdif_out_passthru =3D atc_spdif_out_passthru, .capabilities =3D atc_capabilities, + .dedicated_rca_select =3D atc_dedicated_rca_select, .output_switch_get =3D atc_output_switch_get, .output_switch_put =3D atc_output_switch_put, .mic_source_switch_get =3D atc_mic_source_switch_get, diff --git a/sound/pci/ctxfi/ctatc.h b/sound/pci/ctxfi/ctatc.h index 671edc46bd50..ca0a9d5b86d8 100644 --- a/sound/pci/ctxfi/ctatc.h +++ b/sound/pci/ctxfi/ctatc.h @@ -82,6 +82,8 @@ struct ct_atc { const char *chip_name; const char *model_name; =20 + unsigned char rca_state; /* 0 =3D dedicated RCA, 1 =3D 7.1ch Front */ + struct ct_vm *vm; /* device virtual memory manager for this card */ int (*map_audio_buffer)(struct ct_atc *atc, struct ct_atc_pcm *apcm); void (*unmap_audio_buffer)(struct ct_atc *atc, struct ct_atc_pcm *apcm); @@ -113,12 +115,14 @@ struct ct_atc { int (*line_rear_unmute)(struct ct_atc *atc, unsigned char state); int (*line_in_unmute)(struct ct_atc *atc, unsigned char state); int (*mic_unmute)(struct ct_atc *atc, unsigned char state); + int (*rca_unmute)(struct ct_atc *atc, unsigned char state); int (*spdif_out_unmute)(struct ct_atc *atc, unsigned char state); int (*spdif_in_unmute)(struct ct_atc *atc, unsigned char state); int (*spdif_out_get_status)(struct ct_atc *atc, unsigned int *status); int (*spdif_out_set_status)(struct ct_atc *atc, unsigned int status); int (*spdif_out_passthru)(struct ct_atc *atc, unsigned char state); struct capabilities (*capabilities)(struct ct_atc *atc); + void (*dedicated_rca_select)(struct ct_atc *atc); int (*output_switch_get)(struct ct_atc *atc); int (*output_switch_put)(struct ct_atc *atc, int position); int (*mic_source_switch_get)(struct ct_atc *atc); diff --git a/sound/pci/ctxfi/ctdaio.c b/sound/pci/ctxfi/ctdaio.c index f012d47689d1..1c8f8efd836c 100644 --- a/sound/pci/ctxfi/ctdaio.c +++ b/sound/pci/ctxfi/ctdaio.c @@ -45,6 +45,7 @@ static const struct daio_rsc_idx idx_20k2[NUM_DAIOTYP] = =3D { [LINEO4] =3D {.left =3D 0x70, .right =3D 0x71}, [LINEIM] =3D {.left =3D 0x45, .right =3D 0xc5}, [MIC] =3D {.left =3D 0x55, .right =3D 0xd5}, + [RCA] =3D {.left =3D 0x30, .right =3D 0x31}, [SPDIFOO] =3D {.left =3D 0x00, .right =3D 0x01}, [SPDIFIO] =3D {.left =3D 0x05, .right =3D 0x85}, }; @@ -123,6 +124,7 @@ static unsigned int daio_device_index(enum DAIOTYP type= , struct hw *hw) case LINEO4: return 6; case LINEIM: return 4; case MIC: return 5; + case RCA: return 3; default: return -EINVAL; } default: diff --git a/sound/pci/ctxfi/ctdaio.h b/sound/pci/ctxfi/ctdaio.h index b337da2de8b5..99d55f19e3ca 100644 --- a/sound/pci/ctxfi/ctdaio.h +++ b/sound/pci/ctxfi/ctdaio.h @@ -31,6 +31,7 @@ enum DAIOTYP { LINEIM, SPDIFIO, /* S/PDIF In (Flexijack/Optical) on the card */ MIC, /* Dedicated mic on Titanium HD */ + RCA, SPDIFI1, /* S/PDIF In on internal Drive Bay */ NUM_DAIOTYP }; diff --git a/sound/pci/ctxfi/cthardware.h b/sound/pci/ctxfi/cthardware.h index d29b4e5b3fcc..84ea690763e7 100644 --- a/sound/pci/ctxfi/cthardware.h +++ b/sound/pci/ctxfi/cthardware.h @@ -62,6 +62,7 @@ struct card_conf { struct capabilities { unsigned int digit_io_switch:1; unsigned int dedicated_mic:1; + unsigned int dedicated_rca:1; unsigned int output_switch:1; unsigned int mic_source_switch:1; }; diff --git a/sound/pci/ctxfi/cthw20k1.c b/sound/pci/ctxfi/cthw20k1.c index 60cc1d14453a..ea0a928937b6 100644 --- a/sound/pci/ctxfi/cthw20k1.c +++ b/sound/pci/ctxfi/cthw20k1.c @@ -1775,6 +1775,7 @@ static struct capabilities hw_capabilities(struct hw = *hw) /* SB073x and Vista compatible cards have no digit IO switch */ cap.digit_io_switch =3D !(hw->model =3D=3D CTSB073X || hw->model =3D=3D C= TUAA); cap.dedicated_mic =3D 0; + cap.dedicated_rca =3D 0; cap.output_switch =3D 0; cap.mic_source_switch =3D 0; =20 diff --git a/sound/pci/ctxfi/cthw20k2.c b/sound/pci/ctxfi/cthw20k2.c index 5d39bc943648..214a83977a70 100644 --- a/sound/pci/ctxfi/cthw20k2.c +++ b/sound/pci/ctxfi/cthw20k2.c @@ -1930,6 +1930,7 @@ static struct capabilities hw_capabilities(struct hw = *hw) =20 cap.digit_io_switch =3D 0; cap.dedicated_mic =3D hw->model =3D=3D CTSB1270; + cap.dedicated_rca =3D 0; cap.output_switch =3D hw->model =3D=3D CTSB1270; cap.mic_source_switch =3D hw->model =3D=3D CTSB1270; =20 diff --git a/sound/pci/ctxfi/ctmixer.c b/sound/pci/ctxfi/ctmixer.c index 496682613db5..55224a73cf8e 100644 --- a/sound/pci/ctxfi/ctmixer.c +++ b/sound/pci/ctxfi/ctmixer.c @@ -547,8 +547,14 @@ static void do_switch(struct ct_atc *atc, enum CTALSA_= MIXER_CTL type, int state) atc->mic_unmute(atc, state); else if (MIXER_SPDIFI_C_S =3D=3D type) atc->spdif_in_unmute(atc, state); - else if (MIXER_WAVEF_P_S =3D=3D type) - atc->line_front_unmute(atc, state); + else if (MIXER_WAVEF_P_S =3D=3D type) { + if (cap.dedicated_rca) { + atc->rca_unmute(atc, atc->rca_state ? 0 : state); + atc->line_front_unmute(atc, atc->rca_state ? state : 0); + } else { + atc->line_front_unmute(atc, state); + } + } else if (MIXER_WAVES_P_S =3D=3D type) atc->line_surround_unmute(atc, state); else if (MIXER_WAVEC_P_S =3D=3D type) @@ -612,6 +618,57 @@ static struct snd_kcontrol_new swh_ctl =3D { .put =3D ct_alsa_mix_switch_put }; =20 +static int dedicated_rca_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *info) +{ + static const char *const names[2] =3D { + "RCA", "Front" + }; + + return snd_ctl_enum_info(info, 1, 2, names); +} + +static int dedicated_rca_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct ct_atc *atc =3D snd_kcontrol_chip(kcontrol); + + ucontrol->value.enumerated.item[0] =3D atc->rca_state; + return 0; +} + +static int dedicated_rca_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct ct_atc *atc =3D snd_kcontrol_chip(kcontrol); + unsigned char rca_state =3D ucontrol->value.enumerated.item[0]; + unsigned char state; + + if (rca_state > 1) + return -EINVAL; + + if (rca_state =3D=3D atc->rca_state) + return 0; + + state =3D get_switch_state(atc->mixer, MIXER_WAVEF_P_S); + do_switch(atc, MIXER_WAVEF_P_S, 0); + + atc->rca_state =3D rca_state; + atc->dedicated_rca_select(atc); + + do_switch(atc, MIXER_WAVEF_P_S, state); + + return 1; +} + +static struct snd_kcontrol_new rca_ctl =3D { + .iface =3D SNDRV_CTL_ELEM_IFACE_MIXER, + .name =3D "Dedicated Output Playback Enum", + .info =3D dedicated_rca_info, + .get =3D dedicated_rca_get, + .put =3D dedicated_rca_put, +}; + static int ct_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { @@ -784,7 +841,17 @@ static int ct_mixer_kcontrols_create(struct ct_mixer *= mixer) if (err) return err; } - atc->line_front_unmute(atc, 1); + + if (cap.dedicated_rca) { + err =3D ct_mixer_kcontrol_new(mixer, &rca_ctl); + if (err) + return err; + + atc->line_front_unmute(atc, 0); + atc->rca_unmute(atc, 1); + } else { + atc->line_front_unmute(atc, 1); + } set_switch_state(mixer, MIXER_WAVEF_P_S, 1); atc->line_surround_unmute(atc, 0); set_switch_state(mixer, MIXER_WAVES_P_S, 0); --=20 2.52.0 From nobody Tue Dec 2 01:05:43 2025 Received: from sender3-op-o12.zoho.com (sender3-op-o12.zoho.com [136.143.184.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B07E52E7185; Fri, 21 Nov 2025 15:22:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.184.12 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763738574; cv=pass; b=cEJ1FaldQ6d8ko00TrPnnpqpS3GnpP2U1nVobHNJ+H1M9zm1veABMoNWh7xXE4IZL3e+OdEPW4AUGm/9VIBC9MkE8TDUzy5V6IbOUJRZczqAyy8ld/EWFOjgf0PnxPECFWj6NWI+rfEFkXhDyu3iuzNkjkkJNYt+HOe4craQ0eI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763738574; c=relaxed/simple; bh=92z/KNlP1NEFCpm2Yser7QCAn0uhy1m8CuqWxt4iyqQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sMnelVwEdyHecpFBBow7SwDejHYS/POa8xrvD5blGw8eM99Se6YKq5M5WYzKNi2z2EBqeUAzolrOknn3CoZj4AhmIIA7wbp3Emg9tT1ZewIr9ucRp4DVXZ3ns+05S5C0SkOvyJXaCvQtuDAEeArSpLfVJST1hC699hMGeX3QblY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=harin.net; spf=pass smtp.mailfrom=harin.net; dkim=pass (2048-bit key) header.d=harin.net header.i=me@harin.net header.b=aNAn/wpe; arc=pass smtp.client-ip=136.143.184.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=harin.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=harin.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=harin.net header.i=me@harin.net header.b="aNAn/wpe" ARC-Seal: i=1; a=rsa-sha256; t=1763738563; cv=none; d=zohomail.com; s=zohoarc; b=C7hmLbee6UpgdByCICpu3yYSXKt9rqQnCueMeHPVTIl6pD1NLJxhGKeZ/oTWpl3BqL7CbDrLuCpKa89ejbpKKUKowpOig3uiASjMczGmFkzySNa3EsfrO0vEY9L3WvH9njJq1GhNgBhelkx4ZVjhrf2tMmwp+JXiOv47XJMfII8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1763738563; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=xUCZJUR1KrfKjFjmOxBQPeEte4Hoy97k3kE5KkFfS+o=; b=SIfMY3QwwrYVrPIloK3yGRfVuq9HTxhVMiMfnrUVX9VEZtKnSiE0A9YTG3nriC7PIlSvL5UM8vEgV4UujqD1zbhCEReoz5C/1ATHTruKjcYG7QAOrrd5A8pdUqk5flspHOa0+A1eHX8Sf6dA3uHq9rJZAh3Bp4J+Z0dHQ1x2E/A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=harin.net; spf=pass smtp.mailfrom=me@harin.net; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1763738563; s=zmail; d=harin.net; i=me@harin.net; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To; bh=xUCZJUR1KrfKjFjmOxBQPeEte4Hoy97k3kE5KkFfS+o=; b=aNAn/wpeBrNzrNEd+fcBYclCFle08Acs2MziWyXGQ4RS9GQ01WpgQOgsnFqwitvX 4U8RkgS8yj3E6vtgEWRrP1BMauWy02pnclVmL+dKzJtd0pxLYKFxPZ8GDNC63bgPOMO s/+vLtmWUgE8l74ezjcwA/PknNvh/8iA+BW63Xi+lIPswpUF6r5aRdEDlAU0KkL3s5V S+vXaJ1lygM6zbxq5JW2LEf6vyhThF8Kz+jwuQaMOG/zM0ZWZe8dt1pwj2SSwuORwqA zuV4I69wTkRgZ5YRawy2Ufx1P0Vu2xex5MN4jgghyRV/BMJvGid8KOkioG2Aj8Jf+2G KWTSQ0icJQ== Received: by mx.zohomail.com with SMTPS id 1763738560824638.7647366437496; Fri, 21 Nov 2025 07:22:40 -0800 (PST) From: Harin Lee To: Jaroslav Kysela , Takashi Iwai Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Harin Lee Subject: [PATCH v2 6/6] ALSA: ctxfi: Add support for Onkyo SE-300PCIE (OK0010) Date: Sat, 22 Nov 2025 00:22:20 +0900 Message-ID: <20251121152221.1152523-7-me@harin.net> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251121152221.1152523-1-me@harin.net> References: <20251121152221.1152523-1-me@harin.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" Add support for the Onkyo SE-300PCIE, a Creative X-Fi CA20K2-based sound card with a custom hardware implementation that differs significantly from other CA20K2-based variants. Changes: - PCI quirk entry for OK0010 - Port 0x3 is utilized for dedicated RCA output (configured as I2S) - Modified GPIO pin mappings and states - 4-channel simultaneous ADC input support for line and microphone capture without input switching (similar to SB1270) - Simplified ADC initialization (no manual setup required) Signed-off-by: Harin Lee --- sound/pci/ctxfi/ctatc.c | 7 +++++- sound/pci/ctxfi/ctdaio.h | 2 +- sound/pci/ctxfi/cthardware.h | 1 + sound/pci/ctxfi/cthw20k2.c | 45 ++++++++++++++++++++++++++---------- 4 files changed, 41 insertions(+), 14 deletions(-) diff --git a/sound/pci/ctxfi/ctatc.c b/sound/pci/ctxfi/ctatc.c index 69dad9ebbd8f..62432510eb2f 100644 --- a/sound/pci/ctxfi/ctatc.c +++ b/sound/pci/ctxfi/ctatc.c @@ -63,6 +63,7 @@ static const struct snd_pci_quirk subsys_20k2_list[] =3D { SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_CREATIVE, 0xf000, PCI_SUBDEVICE_ID_CREATIVE_HENDRIX, "HENDRIX", CTHENDRIX), + SND_PCI_QUIRK(0x160b, 0x0101, "OK0010", CTOK0010), { } /* terminator */ }; =20 @@ -78,6 +79,7 @@ static const char *ct_subsys_name[NUM_CTCARDS] =3D { [CTHENDRIX] =3D "Hendrix", [CTSB0880] =3D "SB0880", [CTSB1270] =3D "SB1270", + [CTOK0010] =3D "OK0010", [CT20K2_UNKNOWN] =3D "Unknown", }; =20 @@ -1535,8 +1537,10 @@ static void atc_connect_resources(struct ct_atc *atc) dao->ops->set_right_input(dao, rscs[1]); } =20 - if (cap.dedicated_rca) + if (cap.dedicated_rca) { + /* SE-300PCIE has a dedicated DAC for the RCA. */ atc_dedicated_rca_select(atc); + } =20 dai =3D container_of(atc->daios[LINEIM], struct dai, daio); atc_connect_dai(atc->rsc_mgrs[SRC], dai, @@ -1549,6 +1553,7 @@ static void atc_connect_resources(struct ct_atc *atc) =20 if (cap.dedicated_mic) { /* Titanium HD has a dedicated ADC for the Mic. */ + /* SE-300PCIE has a 4-channel ADC. */ dai =3D container_of(atc->daios[MIC], struct dai, daio); atc_connect_dai(atc->rsc_mgrs[SRC], dai, (struct src **)&atc->srcs[4], diff --git a/sound/pci/ctxfi/ctdaio.h b/sound/pci/ctxfi/ctdaio.h index 99d55f19e3ca..ff77d55539a5 100644 --- a/sound/pci/ctxfi/ctdaio.h +++ b/sound/pci/ctxfi/ctdaio.h @@ -31,7 +31,7 @@ enum DAIOTYP { LINEIM, SPDIFIO, /* S/PDIF In (Flexijack/Optical) on the card */ MIC, /* Dedicated mic on Titanium HD */ - RCA, + RCA, /* Dedicated RCA on SE-300PCIE */ SPDIFI1, /* S/PDIF In on internal Drive Bay */ NUM_DAIOTYP }; diff --git a/sound/pci/ctxfi/cthardware.h b/sound/pci/ctxfi/cthardware.h index 84ea690763e7..a3051fdd31f6 100644 --- a/sound/pci/ctxfi/cthardware.h +++ b/sound/pci/ctxfi/cthardware.h @@ -38,6 +38,7 @@ enum CTCARDS { CTHENDRIX, CTSB0880, CTSB1270, + CTOK0010, CT20K2_UNKNOWN, NUM_CTCARDS /* This should always be the last */ }; diff --git a/sound/pci/ctxfi/cthw20k2.c b/sound/pci/ctxfi/cthw20k2.c index 214a83977a70..e007d1122441 100644 --- a/sound/pci/ctxfi/cthw20k2.c +++ b/sound/pci/ctxfi/cthw20k2.c @@ -910,7 +910,7 @@ static int dao_commit_write(struct hw *hw, unsigned int= idx, void *blk) struct dao_ctrl_blk *ctl =3D blk; =20 if (ctl->dirty.bf.atxcsl) { - if (idx < 4) { + if ((idx < 4) && ((hw->model !=3D CTOK0010) || (idx < 3))) { /* S/PDIF SPOSx */ hw_write_20kx(hw, AUDIO_IO_TX_CSTAT_L+0x40*idx, ctl->atxcsl); @@ -985,11 +985,11 @@ static int daio_mgr_dsb_dao(void *blk, unsigned int i= dx) return 0; } =20 -static int daio_mgr_dao_init(struct hw *hw __maybe_unused, void *blk, unsi= gned int idx, unsigned int conf) +static int daio_mgr_dao_init(struct hw *hw, void *blk, unsigned int idx, u= nsigned int conf) { struct daio_mgr_ctrl_blk *ctl =3D blk; =20 - if (idx < 4) { + if ((idx < 4) && ((hw->model !=3D CTOK0010) || (idx < 3))) { /* S/PDIF output */ switch ((conf & 0xf)) { case 1: @@ -1176,6 +1176,10 @@ static int hw_daio_init(struct hw *hw, const struct = daio_conf *info) hw_write_20kx(hw, AUDIO_IO_MCLK, 0x21011111); hw_write_20kx(hw, AUDIO_IO_TX_BLRCLK, 0x21212121); hw_write_20kx(hw, AUDIO_IO_RX_BLRCLK, 0); + } else if ((4 =3D=3D info->msr) && (hw->model =3D=3D CTOK0010)) { + hw_write_20kx(hw, AUDIO_IO_MCLK, 0x21212121); + hw_write_20kx(hw, AUDIO_IO_TX_BLRCLK, 0x21212121); + hw_write_20kx(hw, AUDIO_IO_RX_BLRCLK, 0); } else { dev_alert(hw->card->dev, "ERROR!!! Invalid sampling rate!!!\n"); @@ -1183,7 +1187,7 @@ static int hw_daio_init(struct hw *hw, const struct d= aio_conf *info) } =20 for (i =3D 0; i < 8; i++) { - if (i <=3D 3) { + if ((i < 4) && ((hw->model !=3D CTOK0010) || (i < 3))) { /* This comment looks wrong since loop is over 4 */ /* channels and emu20k2 supports 4 spdif IOs. */ /* 1st 3 channels are SPDIFs (SB0960) */ @@ -1637,6 +1641,13 @@ static int hw_dac_init(struct hw *hw, const struct d= ac_conf *info) hw_write_20kx(hw, GPIO_DATA, data); hw_dac_start(hw); return 0; + } else if (hw->model =3D=3D CTOK0010) { + hw_dac_stop(hw); + data =3D hw_read_20kx(hw, GPIO_DATA); + data |=3D 0x1000; + hw_write_20kx(hw, GPIO_DATA, data); + hw_dac_start(hw); + return 0; } =20 /* Set DAC reset bit as output */ @@ -1756,9 +1767,11 @@ static int hw_dac_init(struct hw *hw, const struct d= ac_conf *info) static int hw_is_adc_input_selected(struct hw *hw, enum ADCSRC type) { u32 data; - if (hw->model =3D=3D CTSB1270) { + if ((hw->model =3D=3D CTSB1270) || (hw->model =3D=3D CTOK0010)) { /* Titanium HD has two ADC chips, one for line in and one */ - /* for MIC. We don't need to switch the ADC input. */ + /* for MIC. Also, SE-300PCIE has a single ADC chip that */ + /* simultaneously supports 4-channel input. We don't need */ + /* to switch the ADC input. */ return 1; } data =3D hw_read_20kx(hw, GPIO_DATA); @@ -1846,7 +1859,7 @@ static void hw_adc_start(struct hw *hw) msleep(50); } =20 -static void __maybe_unused hw_adc_reset(struct hw *hw) +static void hw_adc_reset(struct hw *hw) { hw_adc_stop(hw); hw_adc_start(hw); @@ -1862,6 +1875,12 @@ static int hw_adc_init(struct hw *hw, const struct a= dc_conf *info) data |=3D (0x1 << 15); hw_write_20kx(hw, GPIO_CTRL, data); =20 + if (hw->model =3D=3D CTOK0010) { + /* Manual ADC setup for SE-300PCIE is not needed. */ + hw_adc_reset(hw); + return 0; + } + /* Initialize I2C */ err =3D hw20k2_i2c_init(hw, 0x1A, 1, 1); if (err < 0) { @@ -1929,8 +1948,8 @@ static struct capabilities hw_capabilities(struct hw = *hw) struct capabilities cap; =20 cap.digit_io_switch =3D 0; - cap.dedicated_mic =3D hw->model =3D=3D CTSB1270; - cap.dedicated_rca =3D 0; + cap.dedicated_mic =3D (hw->model =3D=3D CTSB1270) || (hw->model =3D=3D CT= OK0010); + cap.dedicated_rca =3D hw->model =3D=3D CTOK0010; cap.output_switch =3D hw->model =3D=3D CTSB1270; cap.mic_source_switch =3D hw->model =3D=3D CTSB1270; =20 @@ -2167,15 +2186,17 @@ static int hw_card_init(struct hw *hw, struct card_= conf *info) /* Reset all SRC pending interrupts */ hw_write_20kx(hw, SRC_IP, 0); =20 - if (hw->model !=3D CTSB1270) { + if (hw->model =3D=3D CTSB1270) { + hw_write_20kx(hw, GPIO_CTRL, 0x9E5F); + } else if (hw->model =3D=3D CTOK0010) { + hw_write_20kx(hw, GPIO_CTRL, 0x9902); + } else { /* TODO: detect the card ID and configure GPIO accordingly. */ /* Configures GPIO (0xD802 0x98028) */ /*hw_write_20kx(hw, GPIO_CTRL, 0x7F07);*/ /* Configures GPIO (SB0880) */ /*hw_write_20kx(hw, GPIO_CTRL, 0xFF07);*/ hw_write_20kx(hw, GPIO_CTRL, 0xD802); - } else { - hw_write_20kx(hw, GPIO_CTRL, 0x9E5F); } /* Enable audio ring */ hw_write_20kx(hw, MIXER_AR_ENABLE, 0x01); --=20 2.52.0