From nobody Tue Dec 2 00:26:35 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 08CB38F49; Mon, 24 Nov 2025 18:05:19 +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=1764007522; cv=pass; b=uVqzyWruvMVSkwiw8o4g/Ro1jIPmcmVKJSsH7HSDoaN63AnMqRJ7EUexIzhIliHm6rNi6jas+mdA1pi9Sc6x8ptr0S1tIejHsLqDgnKcmnrzpKy/e29n56ypKRLYKgv0kkR9K3G6/1sidKSZDAGVt2tyTU7o9UAOzDxrtfYYnUo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764007522; c=relaxed/simple; bh=U5/e7P29lKlkUX4b8STHb32Dh50bg29aLAgjK7aYkI4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LxE90Mg9YaAV1ZjiaMx+GuatlGpi7SR+DURmIqSzRuaYZtRc4o5168dZfrHreynpXTWYBUz4yiAj3DbQemNNx4PhvZXtdghhtygfjwux7OKbQzjb5mdCDWn7NKoxC6KiyRl+QpJycjD5Y9WF+TBfbnTygo0jecBMijhhX0SrcaM= 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=KfagkMXK; 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="KfagkMXK" ARC-Seal: i=1; a=rsa-sha256; t=1764007510; cv=none; d=zohomail.com; s=zohoarc; b=KjMFyKvmkK69HLzryKcw1y694Ug6jRyZFHCirVhCwfeLcsmQIGFu7Vj7nKlxzOTRfrYuK5ykog7RYth/vfTApb+vRj++HEeXbjYHIz70NJgJ/Mo9exbeP3uz4tSeKwdbaRx373Akz0caBT3+Sd5PnU/vHJY3NY+53VpcEZrJ8y4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764007510; 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=SIg51MxwoVW0JxgVem/2DmgqiXe0gRaLD7UdHCtHRbzxzd68kPDGN9vC+1+eoUKhJjoOjvlGxEp3zVFVZWl/mFXOxpAjEuKLa2MT8CEuiyrpDZnP/EgBJw/p7WUdFDHpmhdBuGYGwL7GJRx9CAeKBiVyvm19YbmAKD8lD1JizvA= 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=1764007510; 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=KfagkMXKbS3cbB3Kruv++7p9ZQLOMJUJmHaHHuFP64i5yRO8u6ySnShtM150pioA ZHsyppwLE7ye1v5i7uwzfi0bvod6/EFR+kbQduhxL4bccBS/wdlTkVIsvB0JeKYOXJ8 RROCANhJMuH3Oq54zyA40jJ0PicSk4lHl6Ur0Iw/29o4S/lnzkwkejKI+qiClu9zrp3 2vNL9c+f81l3UKtfjyWQo/FVTSQefwzf9UB5jXBnHoY2nvLn/eF7ij55zvVmnTORknj rBYx1lfbDLstbG86yOvZXpcjBFKYx58M0DMF1eiMv1NSfHWZ/E3Rtply2sj4VZ+VegB Y0g2NPUkOg== Received: by mx.zohomail.com with SMTPS id 1764007508413227.3001793402335; Mon, 24 Nov 2025 10:05:08 -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 v3 1/6] ALSA: ctxfi: Add hw parameter to daio_mgr_dao_init() Date: Tue, 25 Nov 2025 03:04:56 +0900 Message-ID: <20251124180501.2760421-2-me@harin.net> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251124180501.2760421-1-me@harin.net> References: <20251124180501.2760421-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 00:26:35 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 027D2318146; Mon, 24 Nov 2025 18:05:22 +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=1764007525; cv=pass; b=gPbfgPzc/jH5v+Tq2khxCoj3QT097iBeceCmGrCK2ClIT6zQC6eYhT49NJja76Iim1WEqb7V8ndUBUgxxEzXtdSKnpRB/kRn8ydGU/zzoPBcVgplpngv/OhKs+m/Ymrq9OYm8DHmedVq9xHQdAFSlTbfHEcAifTi4X93/ciUv0c= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764007525; c=relaxed/simple; bh=4hN2+mR9RXFyMchseG+eh5R/NumPRLG/RBqLbk3clVc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V0qEUSma2Lp17rg1TgvFgtATAZSIkvUg4vE9fw5ZorX5mgM4Sd5K8Cz6yOCm4BqALCz3PSuoGWkQ2Q6tQCXp+jSkJrKWpl1jyYn+boHYv9SruXQZoWpOM1XW7jgqTbu/6NQoW+Cou0+n3qJcBq6fjjhNG7Lmv3t2/OZHlNYnQuA= 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=AqEBgztS; 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="AqEBgztS" ARC-Seal: i=1; a=rsa-sha256; t=1764007512; cv=none; d=zohomail.com; s=zohoarc; b=ECTXlq1JajjdDgnfh2xW3M6m05k0VNmuxzewLB5C9dhlnRLJUuENcaIos870GZ8eMwhtWOL8sUxJZvODmUuLyZWY48DGe+0T/t8gswoN/TT8yV8h644Ufm46YLoY12NvXCGe9q3SoPkW6pGbmLfXIr/OQEHb/p2d+i+OKDoX+MQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764007512; 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=kPtKC5L/MDvmvbkp2zc7F/3nVGpk6vyxzIxY6/ZsYruTl3hNmPOQY2bFTnKlEECeKUXl4YNv7pXfCaUS89D8r4Q4B09dFxbS3EhwgjCydhseCwUSd4h194fEfdXKKv4NQTzPtwPCh8+EGN+wPCQ1HEV8Dh7IUDxr3iuZ5Z/esa4= 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=1764007512; 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=AqEBgztS7FigRFOMurt9P1FQs73nv1IkTHBsIHbL3RToZ2pHIc/WPcofdTLeaCWW twnV1bUF1b4cE8skhrwj+Qfv4djanHIyoa+q0rX2dqCGtY1/O0Tr1kKIbZmVUIXiRTL 5argYKawZN8C2JZicjHbwNp6CxiPsXCqVlI8uLuFj55hXX11Cu2xmJsJ7CHnA/LFBgl daLvn8QbtxWzy0TFp2VeSjR1KtyLfWnTsWkBYItT2e3Xj5BPCRG7+ODT4FMT7P4e7rI 9Ll2MWKcUjE5G0OayjPpfzbOrkZWS+kiw1c5Y+ISE7sSMWFUrWVnaNao7yvVNNS4q+S UPNT+xOUxQ== Received: by mx.zohomail.com with SMTPS id 1764007510338893.6534700293031; Mon, 24 Nov 2025 10:05:10 -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 v3 2/6] ALSA: ctxfi: Add ADC helper functions for GPIO Date: Tue, 25 Nov 2025 03:04:57 +0900 Message-ID: <20251124180501.2760421-3-me@harin.net> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251124180501.2760421-1-me@harin.net> References: <20251124180501.2760421-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 00:26:35 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 90063319617; Mon, 24 Nov 2025 18:05:25 +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=1764007527; cv=pass; b=Xy0/NC4cx3uYKtxlAE881sQjoCo4wrHSs1rgpmaCorreHu9ymjFKFmpQIUT6iPR8VfQ5XknepCtGcxVrRGTRxE/mhHPXiXdViFUcnfUEGHNAHnWATllJG7g00SCNY+riVqqw4njqhe4I0Cd6duPfneEp1yMGLdZnyi0K+Jrq93Q= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764007527; c=relaxed/simple; bh=HDHL5D8DEgOsDVNbC1fvjfBH5IAu5jypGKaX3EybQCs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JrO03aNmVjFmU9V8CLYN33e5C1pj0FtKzzuPxSkLlVQowwLA1wcdTxu/uX4DjGrbw3/+jYL17UOFz74HwHXy0CTy7eXayzA0Ge96P+iUXQ88ckKM6EgQdwrAFEy+bHI/GIXw23JtO24ULxeHy6kOAUHedWa17yhAeenEt+421qQ= 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=FX8yXUxw; 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="FX8yXUxw" ARC-Seal: i=1; a=rsa-sha256; t=1764007516; cv=none; d=zohomail.com; s=zohoarc; b=g+SJG3DzwFhAgOrcnAeRB3kRHPEs9qUzbFRRlx0HCFEIdsUMJH9a+g/yXv7qbfvKZd+GyvQMTtCYHEzuC08FOd+amBeBuRmwsQ0D128aRfAXVZUkhVltN1qSH2SYNV7CuTyHD3OVvTCDBjTiyOtIP9e61ec1RQfmuuOhb4VDO2M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764007516; 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=9BShqN328EGTWA1D8qPa1lEvq+k9Fy9fUcEipp5nP5g=; b=Y8zDrxF7RWeckvXl8xzCzc2WJxxdpfGdrDbNm0hdA3SVsrC8X89CL6/Z1DvlhL0y2CEacK+Fff5Y8oI/TQU09LD/b/F4sh0s9zOJT8XiIS+mD2iHMuCfpo2yyNUlhxuHEKUTkiBG6S/Qi03x1mAkUlziDVXIU8U90D7WzV/58DY= 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=1764007516; 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=9BShqN328EGTWA1D8qPa1lEvq+k9Fy9fUcEipp5nP5g=; b=FX8yXUxwVgX4Fi5yTey7zOmS620gpAnEZbr6NXqsRvX25jeBRRaLW3WYcEXo7niQ K459RODrIpfaaJF48stJ7dr9pYM+Ir6M/SXip3j8KSLwy55IMQA1dkeN5JrP1YcC8KS G6YWS8d0hWNNiQTZH2sGxnWJY7hZeYRDvjbmccJxZA79Cz77u2DHCcE38zemDY7GJlO ZR46CDILrteHSmS/OBTG2W1jIK2dTOd/14yp/jzcGDbu4dQxZ9tXy0C6TwAzqIrW35b DnvsTTTOdh9mMtzBpqepS5gu0oOcaRNI//PtbhuDaTUGj8wX4jPqiklI1uB508iRKtn A0hAVb10pg== Received: by mx.zohomail.com with SMTPS id 1764007512128487.2903963776175; Mon, 24 Nov 2025 10:05:12 -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 v3 3/6] ALSA: ctxfi: Use explicit output flag for DAIO resources Date: Tue, 25 Nov 2025 03:04:58 +0900 Message-ID: <20251124180501.2760421-4-me@harin.net> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251124180501.2760421-1-me@harin.net> References: <20251124180501.2760421-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..55bbeb891afc 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 00:26:35 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 0788731770F; Mon, 24 Nov 2025 18:05:24 +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=1764007526; cv=pass; b=V6PPIVpxpA+vCiOvaNlYfbqmpDYQkAReGEE/2Mu3Dqo3MPArDZb/yspKuJIkWuSeMtPO1yQEaMLb2TqC/2jtEMJw6ZOt7xSKQPA/D/mJnSm8mqCkLsZxe6IIO/wL304NnUGT/cDFZcovckZ9VjKss0svQp+gQKpRC9Bc1TqXAGg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764007526; c=relaxed/simple; bh=j58FQUTXArwPNUYV7va7z785ptJUw8Z/oYJHVe0xVIw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R4BWcd0dFWTmNOiWNpuGVhhmNZNtyN1Nyq69OM8VnF9wAfPXFEMmvvoXeIcHXV3YQPiwTuNmrB+jaFbM39bjxV4z2FT95BFU/37/YEsrH4SsIzUX8ORdGMba1+PzZfFAyENQx5C5siAarIRrqio0zH1QKof/HV/wfSsvYT50DUg= 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=eku12sk2; 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="eku12sk2" ARC-Seal: i=1; a=rsa-sha256; t=1764007518; cv=none; d=zohomail.com; s=zohoarc; b=eYHZM0SEVQeytrYePyk1lzSo+i6J0D0D01qH/7Iw9n7w1wXlPq7kSzAgzpdzFat4DSaTvHdwdujTVibyEgXFOuFOuqQn1K+dTNz2viTpPN+tU4UlI08hqEAKIU8Xu3zqEReNNrGdUYu5CL7k7o67UaeVaIJRP6fRxf4F46fNfRY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764007518; 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=neqcLqAo9F3udVjLYJqUnPOjvKlxbs5oBM9j7O9MT90=; b=Uzb3zAk6U7fpZACkXiTWDl8QJPyCtDnSGXSgW1DeWgI7655pqlf9Y3uRCRUDpl/yudf3LzzSEXuK11EJLaFzpfiDCH1FPNUhBqOP/kPrlJJmon2OwiSGhBQjptM1GUdKMq9xGll5Kyj1RMGH38ys3fOAsGMFFbKJRsL5R6XW0ZI= 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=1764007518; 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=neqcLqAo9F3udVjLYJqUnPOjvKlxbs5oBM9j7O9MT90=; b=eku12sk2bYu1PO0ZbBEeUa6X4WecJ8BHJtCS/g61d2L8y8Ectpxn1Ndg3z8ogmjb bGH4lpdVshpqDzPhCK+W/EDY/3ldWFUtp1FFSPcdIYom6Na21b4BRIQDGC0WZJTX5eT 6Wc3GH10Asx6h5DkhqDeTizCsLjRIoAq06QkuhO0rydyD1x/lTQWwQAw+P7iobWT+ev G1fCIfIY6/foQM8dyh+Ss2EK8zMaQg9vzFDDS9YPkmK5/lRyhRlQSV9vI5VD0sMVIUX buuErN8yGJQbzE0tegf5MjEfITXFl0DKsP50Jrm+3wqgolVsEKqj7Vz1YzLjlMomEYN dWU8jAzK+A== Received: by mx.zohomail.com with SMTPS id 1764007515868488.3052882402628; Mon, 24 Nov 2025 10:05:15 -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 v3 4/6] ALSA: ctxfi: Refactor resource alloc for sparse mappings Date: Tue, 25 Nov 2025 03:04:59 +0900 Message-ID: <20251124180501.2760421-5-me@harin.net> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251124180501.2760421-1-me@harin.net> References: <20251124180501.2760421-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 55bbeb891afc..ce2b16722118 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 00:26:35 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 6639931A549; Mon, 24 Nov 2025 18:05:28 +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=1764007530; cv=pass; b=ViJY7lWazmx+Jv92A1BA4oJCy5d9JqbcN8LXsoNWAY/wIO1Q/5O9VZsOHAkk29Ywquz+MCvkIZNWjuig9Th1a0h9WfuXhWeqpzcJrypItpmWBtI9jz21mPMsu/sJT4IANpr/8n8OJ8ARwvcLYSE7SyXU7Bq/+U96HH3Djtp3NZ8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764007530; c=relaxed/simple; bh=WGlcdEM5nCTB8W92vV+6nZScNfhIaF6okes0VwMJMEk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=keW8lacFTGXuLgE3cbWRqfGs6JDUTEji6jlTNLdVqxQl7N4P1d+ZJT+PM2a6TNIbXQzI+rnJtOLkUaZiIBfvn3EJ4WMbx5G5T6y/PxopOKQfxJrr6HpE+nwh1lTi2QSpiPRdfnK3Nipp2C+W39coxyGPHXJQtEIBMqMnmQM9JmU= 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=XyrKgJro; 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="XyrKgJro" ARC-Seal: i=1; a=rsa-sha256; t=1764007521; cv=none; d=zohomail.com; s=zohoarc; b=DeUkQMN99K9U9xhGlg7Hzt0ahWBM3doOL7IEx4gUDysW+FZYaX5VrTY0Pfg+qpbPf09G5Oa6pbi4Q0gT/biWJZIeJ/foDN9PzYAyP+bONEc4j+ktC7jKRt+GhUUKAbwAtK6ydAytEXOiBY1N3t7VrvVDc+0Xw9epWpgi7evedGc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764007521; 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=fCCqOJJv4xYkQ5ocwbpzNh8GMNB5fuOYbUfl2BqSAyw=; b=jPe/14D88lpZda/3726Xv+A3MZx3ZWmwYi5eTeTSR84v30KvkCq3l5fCw5x/KIE2AXXmsRljHH51+R1QBgt5n9uk6VCD3sXLCV0Q/ltsiRKd+zDBNWq9AWTC0OHyZf2gME8MnJETo2jG8OYQA/1dwRp5Vb2DRi8PclrIfzmWBLs= 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=1764007521; 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=fCCqOJJv4xYkQ5ocwbpzNh8GMNB5fuOYbUfl2BqSAyw=; b=XyrKgJro4pbMUsQDwV+XJrfN0gQ8kMFGts467CpbCHjBY7Bb2QP/U/plkSWaAeGN OPHzdzfU7tuoy6TWCF/WMKcUzQgG6RbnOmBgmh45BGWdRSiVcUk0eL55Jrx8dMtm/QW eikVKYD6XU88XebBdmwypXwd2XVLIg9BnpNo0fecTlxaBAUYZ3c+xlEkQiomrfGr1EV E5mk7NkvuDTNs6TpMMOeXFKaU9+3iIO9cWXVFOUeGzsdq+np8fhn2nR7t9DP8sveYlw HyZ9oeZMdiJ7ETbPyD6zsIiOAcAfmroJPP6GoOGnMNOacN9B5rkVCJ/mNhaj8mZsq7Z IgPI5G2AdA== Received: by mx.zohomail.com with SMTPS id 17640075190038.913200250666819; Mon, 24 Nov 2025 10:05:19 -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 v3 5/6] ALSA: ctxfi: Add support for dedicated RCA switching Date: Tue, 25 Nov 2025 03:05:00 +0900 Message-ID: <20251124180501.2760421-6-me@harin.net> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251124180501.2760421-1-me@harin.net> References: <20251124180501.2760421-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 "Analog Playback Route" 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 ce2b16722118..ff3694b3021e 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..fc9fde284fb3 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 int 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 "Analog Playback Route", + .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 00:26:35 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 BFD7531A7E2; Mon, 24 Nov 2025 18:05:29 +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=1764007532; cv=pass; b=njygkkm3O0I0uWu4zi9H3l8FWYiBTdsbqToFso/11KSHZo0B6NQyknE1H9XEQFEeoMeR36ryQYsRSt8kfLYh9qoJFgYZSUpzvYwugKGWtxxVdb4QgdF0+vD12UdUE41GhKNkMz64A4nXxj3Hc4BrSKNY/pZzZ5Kp1maj0PiGAQ8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764007532; c=relaxed/simple; bh=7401UGr7+h3BlvnpUpwHzPHiTe2Qk6Hlcga13wtFwEc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rQAq4CN269AtTi0wGKPVkNc0Y5czFr0F5ljWPIJOlQyULBSVPWK5Qf4JZAN35y2PRgg+rRppVzxkJGGiLF1mIwbFTKucxIoGdoGRzqC5+njVGl2F29hKxPCIYebmhiDgR6uxTocq06iPESInk0E+S7ShloBWDosneUaGwe4tbt8= 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=DgURm4gq; 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="DgURm4gq" ARC-Seal: i=1; a=rsa-sha256; t=1764007522; cv=none; d=zohomail.com; s=zohoarc; b=B2suRi54BFx7ojBjedpAS//yPmRKl54yovMkG88XCOVud4R1GCdW2R/TS2xO60gSsmk63JehU68ihO85srvbfJEaKty5HsmbJ4qmR/2ilOXWuISHvc7b9GC+YoNmUmi1uIedZjlP06Xq10CeF0zdwedwYpYoshaTAoQWZAEsxZc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764007522; 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=Q69W9jti/+m1c2xFxbeaDbtKJEI0tGBSJEGscbGZL5Q=; b=HtoOcbxNPezWPYysHnaywJUS/9l/TkCVE3vmi7epNIKQHIGyxCyU4SSKzXqw/Z9pnvNpvvlJu4qB6rRzlhONxv78ToMoTkYGt/Rxb898KuIRiOtUo/ZTe58cBfCMrgYk2guXIyIJ/cg7fv1LTqjMIaIU9J2ndstbnWLr1Qsneyw= 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=1764007522; 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=Q69W9jti/+m1c2xFxbeaDbtKJEI0tGBSJEGscbGZL5Q=; b=DgURm4gqFU/0wKr0S+zwsHJYCEkk1acxW8fBdpWXBbskVxY3scX1bPj6nBhWeICC X6AhEGvA8+d1pyrify2JIK8MFNooEuXkHHFLXixNkp95nLnXN5IrW65hVx5T247b9K6 14usliw5ak3ZUvw03OIsv27LWGeEZiQSnfdZhY4ded0ioJx9F2B8VEP5n3UBhbdCUhZ 50AfJH6iCwQH507pRTEpoSsWgLom6LSDMSPOO+iGPrByhdjzgv6MxT/ZMYqAttkhUfV r0snYWSs8CvcedJz/E+ALfO1nE8+hANnV47eGL09dRMCK6D967pgbMmagNgwQjYbg2C HXxDH7YLAA== Received: by mx.zohomail.com with SMTPS id 1764007520889459.237676960224; Mon, 24 Nov 2025 10:05:20 -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 v3 6/6] ALSA: ctxfi: Add support for Onkyo SE-300PCIE (OK0010) Date: Tue, 25 Nov 2025 03:05:01 +0900 Message-ID: <20251124180501.2760421-7-me@harin.net> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251124180501.2760421-1-me@harin.net> References: <20251124180501.2760421-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 | 47 +++++++++++++++++++++++++++--------- 4 files changed, 43 insertions(+), 14 deletions(-) diff --git a/sound/pci/ctxfi/ctatc.c b/sound/pci/ctxfi/ctatc.c index ff3694b3021e..227d8c8490e1 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..fac88f5590c9 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,12 @@ 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) { + /* Port 3 is dedicated to RCA on SE-300PCIE */ + if ((idx < 4) && ((hw->model !=3D CTOK0010) || (idx < 3))) { /* S/PDIF output */ switch ((conf & 0xf)) { case 1: @@ -1176,6 +1177,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 +1188,8 @@ 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) { + /* Port 3 is configured as I2S on SE-300PCIE */ + 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 +1643,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 +1769,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 +1861,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 +1877,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 +1950,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 +2188,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