From patchwork Tue Aug 2 03:58:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Joy Zou X-Patchwork-Id: 12934219 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BDE79C19F2D for ; Tue, 2 Aug 2022 03:58:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235528AbiHBD6M (ORCPT ); Mon, 1 Aug 2022 23:58:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232917AbiHBD6I (ORCPT ); Mon, 1 Aug 2022 23:58:08 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2081.outbound.protection.outlook.com [40.107.20.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 170481CB37; Mon, 1 Aug 2022 20:58:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IcRcAaBulbC6NmWkraxv0n2obpmVpG9lJUTmW0Aq8J1zKjC8ETgfItCHS4ee50oXqqoxYBHpv+LMoVPRyE1mOt40O0+Zdq/Wh62OyZg0DkXDZ4H5GhvUvMF99l/Rm0y6zBhxYk/oMnUsRXY2usM5oUAU2c1pfmg6GoAV+nxt1sakJ7g1a9juwia2t/h6mZYV4s2jSCuBYRbyib8PKnAjeZZvH/9a3ODGlXxtPRcxNKuXXrIYWUWQOqYLNXmJStFPmZxYuLw0cDDBCtpL+Cg3tuTFgPwV/b4W4bSIFamtvRr27pV32kUBvxKuHBYhGaMMb1bu0CjIoMd+Vmw5Z7RBYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bOBDvvQ4HlAvg23bMBoclAacQoI9NJ+GIerHnJCPz8c=; b=GZRBipmNuw7IGEWbCkbsOH3RJzqpF7QDJ0oF7TUK0bve7DplNztSsSL5xsYsnRE4un2U2fHGShvOq2lmSojmPKgilK3DkwUcDJQX+lPV/ItMqWoX3+KM28MxTTwxUb4JEwhOEh2dMht7apZjQIVP4eLD1aayutOVNNNMN0JHUVUfb2YFljxdkff1CYxQjwb0onCEuIIK/T14NOPcS+ILhxMj9/YV111zkfgzOv2ISObVoh4XrSw5kK+D2LNfT3HfDx95xwLX5/uGoqghQe4AHBN5TNeAV0I+/YeFyadAghYpMzZLSAc6PbWPqJWKGR0zD5EFM0JQnvEcILPXjYPptw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bOBDvvQ4HlAvg23bMBoclAacQoI9NJ+GIerHnJCPz8c=; b=IHq8RJdsIXVn7WiRZgcXfuSL54rTfLKny7ITPgmGo9luCMFVHN28eKVVWqXSnvKi12oTxeZn0aaqbua1baN5qk7RNHVM15jWvd0ciPBlOUoTlPcju0TsKlhUgaYVwaznzE7tjPZX/fMuHTqcywOqeJKR6fa/vtc7km5XvHEhkhU= Received: from AM6PR04MB5925.eurprd04.prod.outlook.com (2603:10a6:20b:ab::19) by DBAPR04MB7334.eurprd04.prod.outlook.com (2603:10a6:10:1aa::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.16; Tue, 2 Aug 2022 03:58:04 +0000 Received: from AM6PR04MB5925.eurprd04.prod.outlook.com ([fe80::a88e:aa50:65d9:6206]) by AM6PR04MB5925.eurprd04.prod.outlook.com ([fe80::a88e:aa50:65d9:6206%3]) with mapi id 15.20.5482.016; Tue, 2 Aug 2022 03:58:04 +0000 From: Joy Zou To: "vkoul@kernel.org" CC: "S.J. Wang" , "shawnguo@kernel.org" , "s.hauer@pengutronix.de" , "kernel@pengutronix.de" , "festevam@gmail.com" , dl-linux-imx , "dmaengine@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" Subject: FW: [PATCH V2 2/2] dmaengine: imx-sdma: support hdmi audio Thread-Topic: [PATCH V2 2/2] dmaengine: imx-sdma: support hdmi audio Thread-Index: AQHYb0UDxQBEoTyE4k+etryTbMWZ662baA4Q Date: Tue, 2 Aug 2022 03:58:04 +0000 Message-ID: References: <20220524080640.1322388-1-joy.zou@nxp.com> In-Reply-To: <20220524080640.1322388-1-joy.zou@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 5dbeea35-23de-45e8-697a-08da743b33bc x-ms-traffictypediagnostic: DBAPR04MB7334:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: vlw/N8rLWhJcb/UARxfXF9CTUbJPygDyMARVvSbx4VN+1hZKUTmCfpC9sxdL/7ge0uWMjQJa+yaJ4t0RYwWFbSD0i0xYtja96TDwU77X4s06AhuVXUWC8HXid2M3Lq1bXo143sMj5aQGOD/KqrhKzVuP16exiHhmcyUT7YWCeFVDCEEUjhqxzdR0K45P/nVJGuP/0ZSKYlJRGYXH1ioQFfhctERveiLOp7mJkDbJGKbCLmd9oeEUq6lsY0jLVQGS1xuBKJ5ugvy3fuYNoEucQcS3jepQLwsBCGdkuPVD9P1xllKBri0SvpiUBBP3l7jnSwkcWKK2rQfxQLWZUlfDm1Tfc67JD6dhAu9hbBsDjm6HykM2z/FTxxbt6celXQ3C0jLJjmrz9BEBkQOZww6LrvygG6H/PDspMKW39+YVarTXal47CiVyxPhUYO3BOYrOdBxYegLI+jLKYHEGRDM2Y+ZA5pQ5UuDrf/KsYbcvewy8mk+3xUJ5KwKjSAOOXYtEcFfbZREct2gz8fvwAfBgQXSy0o7T37cYNsl9TgdbvHmp8Qfg9SoOhPYHm9kHQE1duvEOcM+NJWemaZAyslqxP7yC+KlbLISptnimkoKYbiDsWhKb5M9OnxDNXnWieIISCvbgBQKsFucJprDbVyQFgpMQ7g4ymxdv8dggPlWeM3L51pfgR+Nm2e8e1EE4ZIM8tgoJuN6mY6hmgnFn2Dlokb4kUH0ny82YJ40uUwkRzofewgWPMqZTVoBvtW3hI8ISE5Y1oi6lh7CRUtOxskP+JLXJTWyB9425vtpu0qpx6wdQvak8FOpBtjil+ylL0C6c x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR04MB5925.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(396003)(346002)(39860400002)(376002)(366004)(136003)(86362001)(38070700005)(38100700002)(122000001)(8676002)(66446008)(64756008)(66556008)(66476007)(4326008)(76116006)(66946007)(6916009)(54906003)(316002)(5660300002)(52536014)(44832011)(2906002)(8936002)(53546011)(6506007)(26005)(9686003)(186003)(83380400001)(71200400001)(41300700001)(7696005)(478600001)(55016003)(33656002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?eucgb2312_cn?b?aDNqRHFFY0tOSWFDdzRaS096?= =?eucgb2312_cn?b?cEYwOTJOaENNZkN0aC9ZcWxMd2dDa2djRDF4Ykk5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Y1T1JSMlNV?= =?eucgb2312_cn?b?N1pha1JzQVNmY1ArNjFBRFo1NkVPaEkralY4elFtUHFCMkVOSlVZUnBnN0RCK1FQ?= =?eucgb2312_cn?b?Sm5TZUpHOVUyais5NUlyL3U3azFhMWtISmErbVF5VFN3QTF0SmlOaC92UUg1cGtv?= =?eucgb2312_cn?b?bStYK3dLVU82UHNxcyt2V2Nkbi9mbHNadStOMzRuQmhCSXlEVkd4OTRJUjZlN2Fa?= =?eucgb2312_cn?b?VUJVaXlUM04xYXpJVmtOTDVhTFFKSHUrUGQzTHFsQllLbHNjUGZHcWYzdFpnMlNW?= =?eucgb2312_cn?b?K2xCb3gzWXNmWlJibnQ0Mk5jM0xzcnBKZmNkSEdvbkNOcE53emsvQ2VWYWh5ZEtM?= =?eucgb2312_cn?b?a1pzR3FWQ0NzejVuSklCOGZQeTVCNDlJOD0=?= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB5925.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5dbeea35-23de-45e8-697a-08da743b33bc X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Aug 2022 03:58:04.5912 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: npd7slt3JtkHCHq7lpC5SxRwXFEuSOvGpRMA0dgdMq4BEQ7RIZP14RXOMfVhOmUi X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7334 Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org Gentle ping... BR Joy Zou -----Original Message----- From: Joy Zou Sent: 2022年5月24日 16:05 To: vkoul@kernel.org Cc: S.J. Wang ; shawnguo@kernel.org; s.hauer@pengutronix.de; kernel@pengutronix.de; festevam@gmail.com; dl-linux-imx ; dmaengine@vger.kernel.org; linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org Subject: [PATCH V2 2/2] dmaengine: imx-sdma: support hdmi audio Add hdmi audio support in sdma. Signed-off-by: Joy Zou --- Changes since v1: moved data type to include/linux/dma/imx-dma.h --- drivers/dma/imx-sdma.c | 38 +++++++++++++++++++++++++++++-------- include/linux/dma/imx-dma.h | 1 + 2 files changed, 31 insertions(+), 8 deletions(-) -- 2.25.1 diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index 8535018ee7a2..e9b8b2e9f7c9 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c @@ -941,7 +941,10 @@ static irqreturn_t sdma_int_handler(int irq, void *dev_id) desc = sdmac->desc; if (desc) { if (sdmac->flags & IMX_DMA_SG_LOOP) { - sdma_update_channel_loop(sdmac); + if (sdmac->peripheral_type != IMX_DMATYPE_HDMI) + sdma_update_channel_loop(sdmac); + else + vchan_cyclic_callback(&desc->vd); } else { mxc_sdma_handle_channel_normal(sdmac); vchan_cookie_complete(&desc->vd); @@ -1061,6 +1064,10 @@ static int sdma_get_pc(struct sdma_channel *sdmac, per_2_emi = sdma->script_addrs->sai_2_mcu_addr; emi_2_per = sdma->script_addrs->mcu_2_sai_addr; break; + case IMX_DMATYPE_HDMI: + emi_2_per = sdma->script_addrs->hdmi_dma_addr; + sdmac->is_ram_script = true; + break; default: dev_err(sdma->dev, "Unsupported transfer type %d\n", peripheral_type); @@ -1112,11 +1119,16 @@ static int sdma_load_context(struct sdma_channel *sdmac) /* Send by context the event mask,base address for peripheral * and watermark level */ - context->gReg[0] = sdmac->event_mask[1]; - context->gReg[1] = sdmac->event_mask[0]; - context->gReg[2] = sdmac->per_addr; - context->gReg[6] = sdmac->shp_addr; - context->gReg[7] = sdmac->watermark_level; + if (sdmac->peripheral_type == IMX_DMATYPE_HDMI) { + context->gReg[4] = sdmac->per_addr; + context->gReg[6] = sdmac->shp_addr; + } else { + context->gReg[0] = sdmac->event_mask[1]; + context->gReg[1] = sdmac->event_mask[0]; + context->gReg[2] = sdmac->per_addr; + context->gReg[6] = sdmac->shp_addr; + context->gReg[7] = sdmac->watermark_level; + } bd0->mode.command = C0_SETDM; bd0->mode.status = BD_DONE | BD_WRAP | BD_EXTD; @@ -1488,7 +1500,7 @@ static struct sdma_desc *sdma_transfer_init(struct sdma_channel *sdmac, desc->sdmac = sdmac; desc->num_bd = bds; - if (sdma_alloc_bd(desc)) + if (bds && sdma_alloc_bd(desc)) goto err_desc_out; /* No slave_config called in MEMCPY case, so do here */ @@ -1653,13 +1665,16 @@ static struct dma_async_tx_descriptor *sdma_prep_dma_cyclic( { struct sdma_channel *sdmac = to_sdma_chan(chan); struct sdma_engine *sdma = sdmac->sdma; - int num_periods = buf_len / period_len; + int num_periods = 0; int channel = sdmac->channel; int i = 0, buf = 0; struct sdma_desc *desc; dev_dbg(sdma->dev, "%s channel: %d\n", __func__, channel); + if (sdmac->peripheral_type != IMX_DMATYPE_HDMI) + num_periods = buf_len / period_len; + sdma_config_write(chan, &sdmac->slave_config, direction); desc = sdma_transfer_init(sdmac, direction, num_periods); @@ -1676,6 +1691,9 @@ static struct dma_async_tx_descriptor *sdma_prep_dma_cyclic( goto err_bd_out; } + if (sdmac->peripheral_type == IMX_DMATYPE_HDMI) + return vchan_tx_prep(&sdmac->vc, &desc->vd, flags); + while (buf < buf_len) { struct sdma_buffer_descriptor *bd = &desc->bd[i]; int param; @@ -1736,6 +1754,10 @@ static int sdma_config_write(struct dma_chan *chan, sdmac->watermark_level |= (dmaengine_cfg->dst_maxburst << 16) & SDMA_WATERMARK_LEVEL_HWML; sdmac->word_size = dmaengine_cfg->dst_addr_width; + } else if (sdmac->peripheral_type == IMX_DMATYPE_HDMI) { + sdmac->per_address = dmaengine_cfg->dst_addr; + sdmac->per_address2 = dmaengine_cfg->src_addr; + sdmac->watermark_level = 0; } else { sdmac->per_address = dmaengine_cfg->dst_addr; sdmac->watermark_level = dmaengine_cfg->dst_maxburst * diff --git a/include/linux/dma/imx-dma.h b/include/linux/dma/imx-dma.h index 8887762360d4..ef72e00fb55e 100644 --- a/include/linux/dma/imx-dma.h +++ b/include/linux/dma/imx-dma.h @@ -40,6 +40,7 @@ enum sdma_peripheral_type { IMX_DMATYPE_ASRC_SP, /* Shared ASRC */ IMX_DMATYPE_SAI, /* SAI */ IMX_DMATYPE_MULTI_SAI, /* MULTI FIFOs For Audio */ + IMX_DMATYPE_HDMI, /* HDMI Audio */ }; enum imx_dma_prio {