From nobody Tue Oct 7 22:51:46 2025 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (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 D9823285C8C; Fri, 4 Jul 2025 07:53:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615614; cv=none; b=GsgsN6FfqH2zK5BTSZ0oV29uY4eqmenYGEdolBsVdFeYGKzlS+UM6X4zVvfDnpicBq3DDBnH4OESzPdZiN51V4xhrx/FoeKDc7SEj/kiBGdVxFn+PeS5gqZqi1DcK+mCIVO64O1hhQid6JRrOKxQH8AMWsgw0IY1vOdu/gndCm8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615614; c=relaxed/simple; bh=XjXb/f4mBC+GMBUn31nFodWyuIyN27+97CH15XpX1Tg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=fMAkAzaxATCU8EuMNbZhK7nTa1MC2tp2cTC+rSCvSvmUpCQ1yoxBNuiZpMelIUWYZYr/vxKCoSSplpl96cDBuRSN9qoAb8nOEIPVuPgeTsyR10FuHJLMCikSqldyjgjK6s8y4nzAUxGCpGB4tw4vHAStaW2LyOF8w9sgls62Ok4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=lbI4DNeo; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="lbI4DNeo" Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5646R4Km018560; Fri, 4 Jul 2025 07:53:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= Flw3+3vxE9NVGKronCkiecrpyoqLvf9P4ImipXtgPsw=; b=lbI4DNeo2iML9g9w BzySqIzDSQw2MZjYY8wptmRPTf/5btTDSMYnCKM+A5hZycmwZ0FwlIfrrChKCTCS tTl6WHOKJoqGYzAlpfXn6++bgbkecQ3c/4P2IAE0KE10aApuNddAo7JCP9DoeoMo IEMmtzlsjbtttOliPf0xwF6/8sP6LEj0cCvR1q/IZg1suDTj0Trn9RzG2AsT4ndE zt/UGBUsEmlguWIQilPT7Kmwl9I4KfzCfYFRQNOoRgmqkthHJ3FihGIKg1+LuXoJ CUDBumWdf45XoKaJwWsk5AB0+P4YipqQMcUCEfiNlfKglM/gLDFTerG7I1UxRKO4 hy7NhA== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 47j8fxu28a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Jul 2025 07:53:27 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA03.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 5647rQlF018147 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 4 Jul 2025 07:53:26 GMT Received: from hu-dikshita-hyd.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Fri, 4 Jul 2025 00:53:23 -0700 From: Dikshita Agarwal Date: Fri, 4 Jul 2025 13:23:01 +0530 Subject: [PATCH 01/25] media: iris: Fix buffer count reporting in internal buffer check Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20250704-iris-video-encoder-v1-1-b6ce24e273cf@quicinc.com> References: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> In-Reply-To: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> To: Vikash Garodia , Abhinav Kumar , Bryan O'Donoghue , Mauro Carvalho Chehab , Hans Verkuil , Stefan Schmidt , "Vedang Nagar" CC: , , , Dikshita Agarwal X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1751615599; l=1216; i=quic_dikshita@quicinc.com; s=20240917; h=from:subject:message-id; bh=XjXb/f4mBC+GMBUn31nFodWyuIyN27+97CH15XpX1Tg=; b=ps0SZCqiLy+VFitAj6ex4pNAfGK4eU/8JlvjlriaH+KtPdjG5sJKrWXJyy+aFGId7V2tSb2LG IexGs4KjMN5AiG3MrR2zEbPr75pQUzYkL8z0yXk7nUrNb9M0fYtFKsm X-Developer-Key: i=quic_dikshita@quicinc.com; a=ed25519; pk=EEvKY6Ar1OI5SWf44FJ1Ebo1KuQEVbbf5UNPO+UHVhM= X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzA0MDA2MCBTYWx0ZWRfX8MysmOHuCu6n +EjL/7zTHX7KKE4c0gwhPQW7lie2rAg+v00phHnHErZYX9pcHAA+mY7znHLhG1z6YVDz+29lHeH QKMvnY9yCtOAloHDoMPBJOnsM8uyB8jFisiaIazEo8ZNwitv1GY6l+r5WCxkNJuTNzVpg0sZCtQ HUlB/dMk5HRs+tpm3b7JrjDY0nUNl7f7RDykCko+GB3cBe/cPL6b0ILIMRxRFFcrZ6Mat9aMLsW xXR6iGpMb5XMIKQs8sOYXlb/A/Sh8C76Qppie+tGiMxpIWBOrrv3xJdG8W3xYo9q4CtkqAgJsVV wyrM9SY3r0/a3ghfautWVcjP0RN42a3KUOxNKfEf2oD5Nwgh+T7Gk/zT3gItGTrHhDmi2TMMHPV N6/SRC6YC9DKmvdRM24T6XK0ZPmRuOwcdCVL8R7D+e2j0nepNe9EsXREa90rNp4qGzKZCm40 X-Proofpoint-GUID: TqA5tFCFowQI2FJDIWuvFNEy_N9atNEE X-Proofpoint-ORIG-GUID: TqA5tFCFowQI2FJDIWuvFNEy_N9atNEE X-Authority-Analysis: v=2.4 cv=TqPmhCXh c=1 sm=1 tr=0 ts=68678877 cx=c_pps a=JYp8KDb2vCoCEuGobkYCKw==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=GEpy-HfZoHoA:10 a=IkcTkHD0fZMA:10 a=Wb1JkmetP80A:10 a=COk6AnOGAAAA:8 a=-BUsXMgqhKYdWNcrEH8A:9 a=QEXdDO2ut3YA:10 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-04_03,2025-07-02_04,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 mlxlogscore=852 suspectscore=0 adultscore=0 phishscore=0 malwarescore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 spamscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507040060 Initialize the count variable to zero before counting unreleased internal buffers in iris_check_num_queued_internal_buffers(). This prevents stale values from previous iterations and ensures accurate error reporting for each buffer type. Without this initialization, the count could accumulate across types, leading to incorrect log messages. Fixes: d2abb1ff5a3c ("media: iris: Verify internal buffer release on close") Signed-off-by: Dikshita Agarwal Reviewed-by: Bryan O'Donoghue Reviewed-by: Vikash Garodia Tested-by: Vikash Garodia # X1E80100 --- drivers/media/platform/qcom/iris/iris_vidc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/platform/qcom/iris/iris_vidc.c b/drivers/media/p= latform/qcom/iris/iris_vidc.c index c417e8c31f806e03555cd5e2a662a6efe5d58f3e..8285bdaf9466d4bea0f89a3b194= 3ed7d6c014b7d 100644 --- a/drivers/media/platform/qcom/iris/iris_vidc.c +++ b/drivers/media/platform/qcom/iris/iris_vidc.c @@ -240,6 +240,7 @@ static void iris_check_num_queued_internal_buffers(stru= ct iris_inst *inst, u32 p =20 for (i =3D 0; i < internal_buffer_count; i++) { buffers =3D &inst->buffers[internal_buf_type[i]]; + count =3D 0; list_for_each_entry_safe(buf, next, &buffers->list, list) count++; if (count) --=20 2.34.1 From nobody Tue Oct 7 22:51:46 2025 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 E032B2857CA; Fri, 4 Jul 2025 07:53:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615623; cv=none; b=HnQ8t6TlDGFZgCVr17IaTSOgW52Hoya5HvspE0QmTluZXb2wqBzCG8YL7wZGvIGC79gvAJX9MwR+168n90ZHhxi+7WAx8SGYz/QAt0L6iEqU/XH3zkQG3n92L8IqkxuCEfDM6Hu5R/fsl9o/MoWNW74Fxg7QJSn6ckgKUJiIUDY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615623; c=relaxed/simple; bh=PPfazh2Q408uklF/v6kVSRHe+a/+PoprrTMStPMs+WM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=g0q5H6CLCH1E/V1ewopYjQ82TaDr2fSLkW7UUJInQdttw7e2uMC4m/gvxA4fkYfuyNRtVSzsnaIQxDPNoWqhq8oqbgbVqYGZzx8pPMumhTxNeqvhn6Tzx1aTutxxLkvxRawPC97PWLO/JdJHdKTx3a1r8XOZFkAdOOhltuymhiw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=Cm86kJSx; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="Cm86kJSx" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5643eqg2007093; Fri, 4 Jul 2025 07:53:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= rH/5s/9SRxA2uKus31tw/QE8fku89JeoKtG5AWsIXTg=; b=Cm86kJSxr1cRaZmS TGo3N+IIxPkBxx43zCwiiOQP1b3gppiOfh3l8/4wfp0X1lL0wBsB22QWEBnfr3k2 VLCD8B6Zt37EwxT51hxao4mWQ1RTukFKTO+fhvo7GGZFMZvZRhNApnb5EpTHQi63 GlWjvKtxxFzRmnoHB0jTGf5FqBo3giGTJz4Uk3ewQNmxf/0pvwbhrTMwhBnRaHgb 7Lkhz+zJsQg2Td0CzuwjYk9KgptwrDRqWV5D9CK9HK9S6Dv+CWXtL6rLdv7mnFYd 4XopgpQrylkvuAjn76LeRKxZFcJGtkfiZPAvs867WIPqX++qwsTQRtdTIfEeNCz3 5SYr3g== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 47kn5jqgpf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Jul 2025 07:53:30 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA04.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 5647rUgx017323 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 4 Jul 2025 07:53:30 GMT Received: from hu-dikshita-hyd.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Fri, 4 Jul 2025 00:53:26 -0700 From: Dikshita Agarwal Date: Fri, 4 Jul 2025 13:23:02 +0530 Subject: [PATCH 02/25] media: iris: Report unreleased PERSIST buffers on session close Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20250704-iris-video-encoder-v1-2-b6ce24e273cf@quicinc.com> References: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> In-Reply-To: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> To: Vikash Garodia , Abhinav Kumar , Bryan O'Donoghue , Mauro Carvalho Chehab , Hans Verkuil , Stefan Schmidt , "Vedang Nagar" CC: , , , Dikshita Agarwal X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1751615599; l=1364; i=quic_dikshita@quicinc.com; s=20240917; h=from:subject:message-id; bh=PPfazh2Q408uklF/v6kVSRHe+a/+PoprrTMStPMs+WM=; b=Iya6S9bUIuJpjxWaKw8i43hTgH8d4PtDeoO0uODiQkbuG+xKbbDQSXSOpSUnwHRDKQrJb+NxL y79aCm+pZieB6n/0HMP6x8Zqv6qGexakcDh8zFlEaMlX8x45Md737AQ X-Developer-Key: i=quic_dikshita@quicinc.com; a=ed25519; pk=EEvKY6Ar1OI5SWf44FJ1Ebo1KuQEVbbf5UNPO+UHVhM= X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Authority-Analysis: v=2.4 cv=KtJN2XWN c=1 sm=1 tr=0 ts=6867887a cx=c_pps a=JYp8KDb2vCoCEuGobkYCKw==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=GEpy-HfZoHoA:10 a=IkcTkHD0fZMA:10 a=Wb1JkmetP80A:10 a=COk6AnOGAAAA:8 a=r7dkYRASveuLtx3RUUQA:9 a=QEXdDO2ut3YA:10 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-ORIG-GUID: 0BUmGl_LCd0EzIJOX-y9nWekPJp8ZmIA X-Proofpoint-GUID: 0BUmGl_LCd0EzIJOX-y9nWekPJp8ZmIA X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzA0MDA2MCBTYWx0ZWRfX6xf42sSq+XRH Ta+u1P1DnoZu4OHx3aVXY+3/tdTlhEmVwxjprkjHTW8qheT/PMmj/xkbKKfwlKdEOzMTLS8JsjU Cj3MZFhHXAgxWKnfIfp5hu10/kc3K7TCGiXm8FGct60ieoQReQ/VhDSa1ZlE35yqe4r4BSxreFA yxQI7+qJt44ULZnr82RZhxNa9i1rU7rKEjYA9k0IZCa/9GgP+2BsD/NW35nu0lhQ4hAhNNLH1xB MItAXttxfFLZQMZnNHfdZM66sxXCG8AhaaC0RxKDF3Z3iXJHIE96jX7v9chJqKWL7Jz1N3t2YpW 4sxOIhwau7s5qvn463X1JFKeu5Rf1ZJ8qgMTh40BmWeluR9jO2gHb9MIV3LKvwME1Dbqt1g3g+n Ac7Y28lH7QcvrDT0HqWy0ydS7C+yK5C6jFkE5IuiIiWjd1kSx7i5YVmq+1VeRUidpD7no11Q X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-04_03,2025-07-02_04,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 bulkscore=0 priorityscore=1501 malwarescore=0 suspectscore=0 mlxscore=0 spamscore=0 adultscore=0 lowpriorityscore=0 phishscore=0 clxscore=1015 mlxlogscore=999 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507040060 Add error reporting for unreleased PERSIST internal buffers in iris_check_num_queued_internal_buffers(). This ensures all buffer types are checked and logged if not freed during session close, helping to detect memory leaks and improve driver robustness. No change to buffer lifecycle or allocation logic. Fixes: d2abb1ff5a3c ("media: iris: Verify internal buffer release on close") Signed-off-by: Dikshita Agarwal Reviewed-by: Vikash Garodia Tested-by: Vikash Garodia # X1E80100 --- drivers/media/platform/qcom/iris/iris_vidc.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/media/platform/qcom/iris/iris_vidc.c b/drivers/media/p= latform/qcom/iris/iris_vidc.c index 8285bdaf9466d4bea0f89a3b1943ed7d6c014b7d..96313856a026efaff40da97eaaa= 63e847172cd57 100644 --- a/drivers/media/platform/qcom/iris/iris_vidc.c +++ b/drivers/media/platform/qcom/iris/iris_vidc.c @@ -247,6 +247,14 @@ static void iris_check_num_queued_internal_buffers(str= uct iris_inst *inst, u32 p dev_err(inst->core->dev, "%d buffer of type %d not released", count, internal_buf_type[i]); } + + buffers =3D &inst->buffers[BUF_PERSIST]; + + count =3D 0; + list_for_each_entry_safe(buf, next, &buffers->list, list) + count++; + if (count) + dev_err(inst->core->dev, "%d buffer of type %d not released", count, buf= ->type); } =20 int iris_close(struct file *filp) --=20 2.34.1 From nobody Tue Oct 7 22:51:46 2025 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 DA4FA2877F3; Fri, 4 Jul 2025 07:53:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615627; cv=none; b=S9izSESE1l7QWdkIyjUY7o3ojOUllJUVavq0z7riu8dN2Ba4duyQiLEib5mza0VUx+5F95sjPJVqenE3/PCg7RsqNSfh+ojTgsVejfotSLGNqLsUXrwAR8FfkQSRmdh73VmZnyO1+fHj5nWmdzpbKwP4pZ9vDg4IozLD9Cdc5Yg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615627; c=relaxed/simple; bh=CCPkkDTnG3P0SeeewUyE2VVrE49g0bg3/xbTp2/W0xQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=KPr5YsKWK4MngDm7vJQ4zIF0/plNhaFr9nq5P8zzrijlHaCFKqErYmyXX018nWMJqvr27omovvcnNyb9+TDuDeP5BpUuVhPaGgS0bkPxeBMS8Y6EG6/4lo1Dnz17Blykirhw+wEQMFPN8ZCmgeod/l65GA4aG87qdCyyuVnc8AY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=jUxbclyX; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="jUxbclyX" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5646Iwpk007227; Fri, 4 Jul 2025 07:53:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= 9XK46q5Hqzobm1M9phw2brCy2RlA73mJMO84guBG4pY=; b=jUxbclyXODoiKt4f OBI4YW/KvW8iSrZXiUhLQoglGD4x3fFISGuyZjfYqDc6PXPKd7ms4LppNCb0McmF j00rDT8GUQYySh0g0QtnfWR407kY1FetguIyhIOYhaCfbP58raGzs+ANexQ0fRfn PJCcjWTptMJHuqv5aAwaqO8Uh3MRAD9J3uyJ3bMoZ+HCXr4gw6f7oVVI3WThYiRM KA6s+DZJokNzFImRhK6qgM1pbYTXMF+6hwHo9bQqsiwz/qzHGMQ5kCPHkueggkz4 FRtwDuSRomr4M3Xiq0namqcBWq2ECxX0gRG+lIMjDkIbGy/R81POCuQkk13U8kVX p6f5lA== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 47kn5jqgpk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Jul 2025 07:53:34 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA02.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 5647rXVf024430 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 4 Jul 2025 07:53:33 GMT Received: from hu-dikshita-hyd.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Fri, 4 Jul 2025 00:53:30 -0700 From: Dikshita Agarwal Date: Fri, 4 Jul 2025 13:23:03 +0530 Subject: [PATCH 03/25] media: iris: Fix memory leak by freeing untracked persist buffer Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20250704-iris-video-encoder-v1-3-b6ce24e273cf@quicinc.com> References: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> In-Reply-To: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> To: Vikash Garodia , Abhinav Kumar , Bryan O'Donoghue , Mauro Carvalho Chehab , Hans Verkuil , Stefan Schmidt , "Vedang Nagar" CC: , , , Dikshita Agarwal X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1751615599; l=1302; i=quic_dikshita@quicinc.com; s=20240917; h=from:subject:message-id; bh=CCPkkDTnG3P0SeeewUyE2VVrE49g0bg3/xbTp2/W0xQ=; b=1tmaWezTVm3wYv6R82Uv3FB71nq1C7kE/rrs6v+RYPJfALmOU5VOR5MLxXgtEPZBEL6GPR6wg 5fiyxBnpCCUD8J4dCanYAkByIyv9ZbJ66xXJpheneYn+IOXcLMY4QBE X-Developer-Key: i=quic_dikshita@quicinc.com; a=ed25519; pk=EEvKY6Ar1OI5SWf44FJ1Ebo1KuQEVbbf5UNPO+UHVhM= X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Authority-Analysis: v=2.4 cv=KtJN2XWN c=1 sm=1 tr=0 ts=6867887e cx=c_pps a=JYp8KDb2vCoCEuGobkYCKw==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=GEpy-HfZoHoA:10 a=IkcTkHD0fZMA:10 a=Wb1JkmetP80A:10 a=COk6AnOGAAAA:8 a=GUxkLdxIJ5orBtzUV8IA:9 a=QEXdDO2ut3YA:10 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-ORIG-GUID: MDj8h39Vs9H-1_zOLpwdpVEEH1PQeQ8f X-Proofpoint-GUID: MDj8h39Vs9H-1_zOLpwdpVEEH1PQeQ8f X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzA0MDA2MCBTYWx0ZWRfXz3JOpMnPgJsU xsMs2/oTDS2Mv1pR6z3WqQnLLGB691R3wGTNB90dWRpa3G6t5cL7em8+WEaecvjvTjZncPapGNA ePHScWD3V+K6uIoaQFUxoDtwvvsmBjftEITqvHUzUNTT8JfYifIFoJwkL4CeNSH0U8eHHyATxCa Cxm9PPNR3H6ZPVbS0b2krYHM3PJVvEa1oZhyFCUfcUGVQD8J/11MMwUrLZEoOQXcdoCDqSl3Ohr vJ++XvVs5XKwmiNmjXHsTvRefHp1lDuP1ljwh/iP1Ldl8KtYaXtKHC06Crsc57yQ1Mq5cfnKqmP gMcvB1Ux227991wm7IECUbu2n6mxDT3QnXK1Ii8eyO3UxGcbqwMj0v4IBO8Wrlw6eVbEZCP1cMr OuSNcRP9P3eUbMtjoWaZqNQRCeRGDVstc4cYdqAbVUUCrh4XEWHun6JVUAZ4uARxuwn0GrxA X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-04_03,2025-07-02_04,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 bulkscore=0 priorityscore=1501 malwarescore=0 suspectscore=0 mlxscore=0 spamscore=0 adultscore=0 lowpriorityscore=0 phishscore=0 clxscore=1015 mlxlogscore=933 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507040060 One internal buffer which is allocated only once per session was not being freed during session close because it was not being tracked as part of internal buffer list which resulted in a memory leak. Add the necessary logic to explicitly free the untracked internal buffer during session close to ensure all allocated memory is released properly. Fixes: 73702f45db81 ("media: iris: allocate, initialize and queue internal = buffers") Signed-off-by: Dikshita Agarwal Reviewed-by: Vikash Garodia Tested-by: Vikash Garodia # X1E80100 --- drivers/media/platform/qcom/iris/iris_buffer.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/media/platform/qcom/iris/iris_buffer.c b/drivers/media= /platform/qcom/iris/iris_buffer.c index 6425e4919e3b0b849ba801ca9e01921c114144cd..9f664c241149362d44d3a8fa65e= 2266f9c2e80e0 100644 --- a/drivers/media/platform/qcom/iris/iris_buffer.c +++ b/drivers/media/platform/qcom/iris/iris_buffer.c @@ -413,6 +413,16 @@ static int iris_destroy_internal_buffers(struct iris_i= nst *inst, u32 plane, bool } } =20 + if (force) { + buffers =3D &inst->buffers[BUF_PERSIST]; + + list_for_each_entry_safe(buf, next, &buffers->list, list) { + ret =3D iris_destroy_internal_buffer(inst, buf); + if (ret) + return ret; + } + } + return 0; } =20 --=20 2.34.1 From nobody Tue Oct 7 22:51:46 2025 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 683D32857C9; Fri, 4 Jul 2025 07:53:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615623; cv=none; b=X+mZOVWEqozYLrEyg4pNGBkGt2PQDVRtjW6lQkWLghdigQ3sF/hn+lj/fJJYS+Vi7SM9n56U/fixpDtfB/VKUTlxpJ6v6D7yikuMgN6+y2wW6BCKuGL6c7+jSSd6eNtTJFA8tFWjg+9h/KZYu3yVLE1H2oVIitExG5HXYxRVPvI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615623; c=relaxed/simple; bh=wHJdsK8MQEBWN+0v8OrbkWnI7FcyAxLzFilTRFaTPOY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=h9ZcLeYpFHJnuwIkBOl0yib1SpBZBxdQGtNKX3z+GFKluTFa8uNV1+vfu3pR4GJWnfpTi8VAkqY3jOqi3eNz+eU9xwH5/W8fuaSoW1oSmphZU9vGh+vQJZ5FL3+7QrKtqaE8WyJjOdLKTEjUfx59FXDfpALLE7FVvDbW3MDaZDk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=GIag+0zZ; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="GIag+0zZ" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5643eqg4007093; Fri, 4 Jul 2025 07:53:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= N2SuE+W08OOlGg/I2V/faD0Je/m3w9qPxGmKEQxe/f0=; b=GIag+0zZSDeQJ7cp mp+GSXOEr4eLvsKkGQkl1sEzr9pbY7KzB8xnBHlfTOcv2d6GndXn4oyxfV8xke0p Xr9hoJpfBifYuC+ueQhGa19zN1xuDyiiqGBXmd4Gcf7bpFluYaEz4rTZtUQCCvQM x7p3J8ih5TsBHXIuY/r4a+2ZXAdmHOlFPkPRU7NPkcOsAGsqDtT6YwDcYgDKNWes 76lDRRwKt22Zqi4gacvw7xUi9RsBkDIrDnu+jsePWucYlLpr/+vpMIyx1TKxXk8b Wtkgm2JgYofO+8hGIqOkO8j+vhHoJdw1YROLi8FgDgUTT/sdqkmnh9prGTGK85ch AItSow== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 47kn5jqgqf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Jul 2025 07:53:37 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA01.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 5647raHN000356 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 4 Jul 2025 07:53:36 GMT Received: from hu-dikshita-hyd.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Fri, 4 Jul 2025 00:53:33 -0700 From: Dikshita Agarwal Date: Fri, 4 Jul 2025 13:23:04 +0530 Subject: [PATCH 04/25] media: iris: Fix buffer timestamp handling Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20250704-iris-video-encoder-v1-4-b6ce24e273cf@quicinc.com> References: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> In-Reply-To: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> To: Vikash Garodia , Abhinav Kumar , Bryan O'Donoghue , Mauro Carvalho Chehab , Hans Verkuil , Stefan Schmidt , "Vedang Nagar" CC: , , , Dikshita Agarwal X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1751615599; l=2551; i=quic_dikshita@quicinc.com; s=20240917; h=from:subject:message-id; bh=wHJdsK8MQEBWN+0v8OrbkWnI7FcyAxLzFilTRFaTPOY=; b=LsntG5aN3F24DI/Vs3meriAfBUd7wM/nwqw9q1xpJb2Loeqho2A6veCNg62xCBPuoCl7zzTdp hVcRjwpmFY/BtmS/apRCpYeyMrbNmvSNL2p4wulsHHikNBMxGUBNWBe X-Developer-Key: i=quic_dikshita@quicinc.com; a=ed25519; pk=EEvKY6Ar1OI5SWf44FJ1Ebo1KuQEVbbf5UNPO+UHVhM= X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Authority-Analysis: v=2.4 cv=KtJN2XWN c=1 sm=1 tr=0 ts=68678881 cx=c_pps a=JYp8KDb2vCoCEuGobkYCKw==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=GEpy-HfZoHoA:10 a=IkcTkHD0fZMA:10 a=Wb1JkmetP80A:10 a=COk6AnOGAAAA:8 a=SLZpxBsjxFweyj1SjAEA:9 a=QEXdDO2ut3YA:10 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-ORIG-GUID: B0PQqBl2eqledDhS0XCPLCiypedhrWgZ X-Proofpoint-GUID: B0PQqBl2eqledDhS0XCPLCiypedhrWgZ X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzA0MDA2MCBTYWx0ZWRfXxWuah/IqyuuQ mAwpDD2TTM12CDwqnDzEUBqX2OzHFsK0SsgNKJ/JeoHtLT7sXwQuAauWDqvTjlsxgvHHAYEzgkn 8wTdhSRyPCNA49wgvFg37ak0jXHGcZyecaiIAex7rR8K3yTapfl3RQqWSjShYlKx5twZMcMKR87 pOKjS+LT5apB3Geyt2fqC0fzWw8mHMiGPn1vhcLiF485G/BiEAdUEHLrX09XEi7YpWe17mubyju pnOnGj/A/IQVFZNEyMyDBJPeNX6Up1Sy2SiKuF9DUweZjP1Z/3FPu8LARm+90YnME0KXD+keE2m K1dUR41jIjhMU69STva0+u7rAcbW/hTfVnHwBTj7hDwtB5//bYjnhEX3UM4DyJz7gdqYlmQ4Wa+ jM9cb+X2tpH9kSwsXoQECsrwbYHZXOwiGX0OyBP67EXDcwmRTsumPM05yrbQemskpSG2Wwe2 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-04_03,2025-07-02_04,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 bulkscore=0 priorityscore=1501 malwarescore=0 suspectscore=0 mlxscore=0 spamscore=0 adultscore=0 lowpriorityscore=0 phishscore=0 clxscore=1015 mlxlogscore=999 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507040060 The internal driver logic operates with timestamps in microseconds while the buffer timestamp received by vb2 is in nanosecond, this mismatch in units causing issue in buffer handling. Update the timestamp handling logic by converting the buffer timestamp to microseconds before using it internally in driver for all the timestamp assignments, comparisons, and metadata handling. Fixes: 17f2a485ca67 ("media: iris: implement vb2 ops for buf_queue and firm= ware response") Signed-off-by: Dikshita Agarwal Reviewed-by: Vikash Garodia Tested-by: Vikash Garodia # X1E80100 --- drivers/media/platform/qcom/iris/iris_buffer.c | 6 +++--- drivers/media/platform/qcom/iris/iris_vdec.c | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/qcom/iris/iris_buffer.c b/drivers/media= /platform/qcom/iris/iris_buffer.c index 9f664c241149362d44d3a8fa65e2266f9c2e80e0..809ce77744f996c23dc07ef9ecb= 3e8e92b709850 100644 --- a/drivers/media/platform/qcom/iris/iris_buffer.c +++ b/drivers/media/platform/qcom/iris/iris_buffer.c @@ -579,14 +579,14 @@ iris_helper_find_buf(struct iris_inst *inst, u32 type= , u32 idx) return v4l2_m2m_dst_buf_remove_by_idx(m2m_ctx, idx); } =20 -static void iris_get_ts_metadata(struct iris_inst *inst, u64 timestamp_ns, +static void iris_get_ts_metadata(struct iris_inst *inst, u64 timestamp_us, struct vb2_v4l2_buffer *vbuf) { u32 mask =3D V4L2_BUF_FLAG_TIMECODE | V4L2_BUF_FLAG_TSTAMP_SRC_MASK; u32 i; =20 for (i =3D 0; i < ARRAY_SIZE(inst->tss); ++i) { - if (inst->tss[i].ts_ns !=3D timestamp_ns) + if (inst->tss[i].ts_us !=3D timestamp_us) continue; =20 vbuf->flags &=3D ~mask; @@ -653,7 +653,7 @@ int iris_vb2_buffer_done(struct iris_inst *inst, struct= iris_buffer *buf) } =20 state =3D VB2_BUF_STATE_DONE; - vb2->timestamp =3D buf->timestamp; + vb2->timestamp =3D buf->timestamp * NSEC_PER_USEC; v4l2_m2m_buf_done(vbuf, state); =20 return 0; diff --git a/drivers/media/platform/qcom/iris/iris_vdec.c b/drivers/media/p= latform/qcom/iris/iris_vdec.c index d670b51c5839d1fad54d34f373cf71d5f3973a96..05340e201e6538b9599387cdd57= 814005b904e76 100644 --- a/drivers/media/platform/qcom/iris/iris_vdec.c +++ b/drivers/media/platform/qcom/iris/iris_vdec.c @@ -561,6 +561,7 @@ iris_vdec_vb2_buffer_to_driver(struct vb2_buffer *vb2, = struct iris_buffer *buf) buf->data_size =3D vb2->planes[0].bytesused - vb2->planes[0].data_offset; buf->flags =3D vbuf->flags; buf->timestamp =3D vb2->timestamp; + do_div(buf->timestamp, NSEC_PER_USEC); buf->attr =3D 0; =20 return 0; --=20 2.34.1 From nobody Tue Oct 7 22:51:46 2025 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 105E92877F4; Fri, 4 Jul 2025 07:53:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615629; cv=none; b=mPwIs4xyrDFvit3i2JPS/I3dxg6D4SzSNOiCrck3UaEFn6wy+GbC38+8QOKLGeqAROWMMv7BFyeWg4uuQ6w6EYqAeiUK9QDkaXwRTQPskn7sp0QegO1l1KgSG86/12futCXMUHiBYAE37Yjy3FZkWeztaf7IqLmprW3933ptqis= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615629; c=relaxed/simple; bh=RNJbZWkTYQTBMx2fNSRet7xZLfc5sRQK7bocJ7lsJ3w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=G4lFz/rAiwtajkwDWwcGd+BTHLShIGWz0EXCHcQc458xBJQE8oqLq3MWyzlnNuZRuZOmRVsXVdUIxbdSnLKXpg0rJMbO95rjrBgymeU6KIjLR4Gofgksmw4+iKdgGvje8AGpcPoIDIafZEsj48xoHyXEpedlVWL2L1Azg3ovOd8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=dpdiGQBG; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="dpdiGQBG" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 563IctQE029572; Fri, 4 Jul 2025 07:53:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= tGAV81va0ndjiQQ/lBves87DuWtGn+AsjOR6jDsOz9Q=; b=dpdiGQBGew6S5T0s bNuuVifg6rK+K6t5E+PfzWQIU460CKzvHpiGFAzqDrs5yMuvoB/NYjMYkRjv0dky UTzsf0ssPRpXo1k0lhtQzUQIJ+gVElcQf+1eLzf0rV5tZUo8V/LLsaCYYIXx9VmZ U2kk5d1ymGS+Zu1Lu20vtrzNFdmu2NOpatzBJ+m8OZ6vPg0rQI4Mz/6TTJ2Zbbe6 3MLWNHaMM9ra+CPA7XVfDQ2Wq1JZMk1Co848X5OE5+kJEfAMFAZ9cPRg0+jsPb7d 67T+0xfbDWhPO8qiODjKMiswNL6g4sZX2c4t1Q3RObVk4FlZnzbvG04/nmC4pbks 96bWAQ== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 47nh9s4bpw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Jul 2025 07:53:40 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA01.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 5647rews000550 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 4 Jul 2025 07:53:40 GMT Received: from hu-dikshita-hyd.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Fri, 4 Jul 2025 00:53:36 -0700 From: Dikshita Agarwal Date: Fri, 4 Jul 2025 13:23:05 +0530 Subject: [PATCH 05/25] media: iris: Fix port streaming handling Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20250704-iris-video-encoder-v1-5-b6ce24e273cf@quicinc.com> References: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> In-Reply-To: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> To: Vikash Garodia , Abhinav Kumar , Bryan O'Donoghue , Mauro Carvalho Chehab , Hans Verkuil , Stefan Schmidt , "Vedang Nagar" CC: , , , Dikshita Agarwal X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1751615599; l=4453; i=quic_dikshita@quicinc.com; s=20240917; h=from:subject:message-id; bh=RNJbZWkTYQTBMx2fNSRet7xZLfc5sRQK7bocJ7lsJ3w=; b=exKh17bLknbyicH220AJYHJdERtOj554xuiwD+4C42BnAXbuyCAt/H882RBrz/EvvZtojWe3n Li8gk7Nx0XgBd0i173B8kQ0kOSQwjsCnm+lTZOTrBqcJoT+b+uFWr4d X-Developer-Key: i=quic_dikshita@quicinc.com; a=ed25519; pk=EEvKY6Ar1OI5SWf44FJ1Ebo1KuQEVbbf5UNPO+UHVhM= X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Authority-Analysis: v=2.4 cv=frrcZE4f c=1 sm=1 tr=0 ts=68678884 cx=c_pps a=JYp8KDb2vCoCEuGobkYCKw==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=GEpy-HfZoHoA:10 a=IkcTkHD0fZMA:10 a=Wb1JkmetP80A:10 a=COk6AnOGAAAA:8 a=KN8zqi05ybdC166h3CMA:9 a=QEXdDO2ut3YA:10 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzA0MDA2MCBTYWx0ZWRfX5AEyi0O4AHyh oNfOx9tqNNpZ/7f0v26Jwj9tOKX9r9mYHOrZJiql7A9UUBfHpAiyc1ATtjLJR5Ne45h7Z8ahqgS N7GnVJvDGx6fMVTY6dTgicjqzpjM16ANl0mBZgmFI9iRuIfKF0s7FQIEX4eJs6qzS5TG1VVRLST a8b08i+Par/U60vgbjvzp66i7HzTkdGJvUwRnmlH4x45LGCBTO0twZmTc1N5/EP+1ZID9V+EDLA ATMtC6gveicWgkwgVR6BGfV4pXlfE95b/1HKMsDNMaTZ6sIUlAt6jYLaXBn2gKD6l9qEW2Nn2r0 LFJK7d+FEk3sTxMY0oxR4NdtfW96yA2sTGE8AI4UQUXAkAqk8maiwyXXaRqa+PsHArWRZjJXMvL Axv5cGqWhie+CtIylcfwWOrhurbtq64A7ilJvINuePwK0eBBKb7bhHDxq03f5KBcjDkBweKW X-Proofpoint-GUID: JL8K27BEaGUYecXmYC7HtD-qEtwe7MG3 X-Proofpoint-ORIG-GUID: JL8K27BEaGUYecXmYC7HtD-qEtwe7MG3 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-04_03,2025-07-02_04,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxlogscore=999 bulkscore=0 spamscore=0 adultscore=0 impostorscore=0 clxscore=1015 lowpriorityscore=0 suspectscore=0 mlxscore=0 priorityscore=1501 malwarescore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507040060 The previous check to block capture port streaming before output port was incorrect and caused some valid usecase to fail. While removing that check allows capture port to enter streaming independently, it also introduced firmware errors due to premature queuing of DPB buffers before the firmware session was fully started which happens only when streamon is called on output port. Fix this by deferring DPB buffer queuing to the firmware until both capture and output are streaming and state is 'STREAMING'. Fixes: 11712ce70f8e ("media: iris: implement vb2 streaming ops") Signed-off-by: Dikshita Agarwal Reviewed-by: Vikash Garodia Tested-by: Vikash Garodia # X1E80100 --- drivers/media/platform/qcom/iris/iris_buffer.c | 27 ++++++++++++++++++++++= ++++ drivers/media/platform/qcom/iris/iris_buffer.h | 1 + drivers/media/platform/qcom/iris/iris_vb2.c | 8 ++++---- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/qcom/iris/iris_buffer.c b/drivers/media= /platform/qcom/iris/iris_buffer.c index 809ce77744f996c23dc07ef9ecb3e8e92b709850..320ebfb833331294ba5ddda8e9c= d243c80633408 100644 --- a/drivers/media/platform/qcom/iris/iris_buffer.c +++ b/drivers/media/platform/qcom/iris/iris_buffer.c @@ -334,6 +334,29 @@ int iris_queue_buffer(struct iris_inst *inst, struct i= ris_buffer *buf) return 0; } =20 +int iris_queue_internal_deferred_buffers(struct iris_inst *inst, enum iris= _buffer_type buffer_type) +{ + struct iris_buffer *buffer, *next; + struct iris_buffers *buffers; + int ret =3D 0; + + buffers =3D &inst->buffers[buffer_type]; + list_for_each_entry_safe(buffer, next, &buffers->list, list) { + if (buffer->attr & BUF_ATTR_PENDING_RELEASE) + continue; + if (buffer->attr & BUF_ATTR_QUEUED) + continue; + + if (buffer->attr & BUF_ATTR_DEFERRED) { + ret =3D iris_queue_buffer(inst, buffer); + if (ret) + return ret; + } + } + + return ret; +} + int iris_queue_internal_buffers(struct iris_inst *inst, u32 plane) { const struct iris_platform_data *platform_data =3D inst->core->iris_platf= orm_data; @@ -358,6 +381,10 @@ int iris_queue_internal_buffers(struct iris_inst *inst= , u32 plane) continue; if (buffer->attr & BUF_ATTR_QUEUED) continue; + if (buffer->type =3D=3D BUF_DPB && inst->state !=3D IRIS_INST_STREAMING= ) { + buffer->attr |=3D BUF_ATTR_DEFERRED; + continue; + } ret =3D iris_queue_buffer(inst, buffer); if (ret) return ret; diff --git a/drivers/media/platform/qcom/iris/iris_buffer.h b/drivers/media= /platform/qcom/iris/iris_buffer.h index 00825ad2dc3a4bd1ace32d7e95d15b95276315b0..b9b011faa13ae72e08545c191cd= cc2f1bcaf9e0a 100644 --- a/drivers/media/platform/qcom/iris/iris_buffer.h +++ b/drivers/media/platform/qcom/iris/iris_buffer.h @@ -105,6 +105,7 @@ int iris_get_buffer_size(struct iris_inst *inst, enum i= ris_buffer_type buffer_ty void iris_get_internal_buffers(struct iris_inst *inst, u32 plane); int iris_create_internal_buffers(struct iris_inst *inst, u32 plane); int iris_queue_internal_buffers(struct iris_inst *inst, u32 plane); +int iris_queue_internal_deferred_buffers(struct iris_inst *inst, enum iris= _buffer_type buffer_type); int iris_destroy_internal_buffer(struct iris_inst *inst, struct iris_buffe= r *buffer); int iris_destroy_all_internal_buffers(struct iris_inst *inst, u32 plane); int iris_destroy_dequeued_internal_buffers(struct iris_inst *inst, u32 pla= ne); diff --git a/drivers/media/platform/qcom/iris/iris_vb2.c b/drivers/media/pl= atform/qcom/iris/iris_vb2.c index 8b17c7c3948798326ed4732ca50ebd98b833401f..e62ed7a57df2debf0a930ad8307= e6d945f589922 100644 --- a/drivers/media/platform/qcom/iris/iris_vb2.c +++ b/drivers/media/platform/qcom/iris/iris_vb2.c @@ -173,9 +173,6 @@ int iris_vb2_start_streaming(struct vb2_queue *q, unsig= ned int count) =20 inst =3D vb2_get_drv_priv(q); =20 - if (V4L2_TYPE_IS_CAPTURE(q->type) && inst->state =3D=3D IRIS_INST_INIT) - return 0; - mutex_lock(&inst->lock); if (inst->state =3D=3D IRIS_INST_ERROR) { ret =3D -EBUSY; @@ -203,7 +200,10 @@ int iris_vb2_start_streaming(struct vb2_queue *q, unsi= gned int count) =20 buf_type =3D iris_v4l2_type_to_driver(q->type); =20 - ret =3D iris_queue_deferred_buffers(inst, buf_type); + if (inst->state =3D=3D IRIS_INST_STREAMING) + ret =3D iris_queue_internal_deferred_buffers(inst, BUF_DPB); + if (!ret) + ret =3D iris_queue_deferred_buffers(inst, buf_type); if (ret) goto error; =20 --=20 2.34.1 From nobody Tue Oct 7 22:51:46 2025 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 5B0502853EB; Fri, 4 Jul 2025 07:53:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615632; cv=none; b=P6NVJW2afX+EA9eP1652Ilh4N1xsk5baWobLwDHzflt/jcd7PqMfkxtFYTuLaNGkG1hMWE5IBr92xFmE4tNw/7I/jwROu+NkDVdhcT3Gqw9Rwlk1GaSRaJjS1U66cjbG6UqBf/BNE3zR/TMJodW+fE+FtWK791vWTLJhgWM4+tw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615632; c=relaxed/simple; bh=0Pf75v5OaEW2TsnHb7bM1RCGbkIAWKJpnd+MVuR3y7U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=g0xumO3nCCKeZUDrEYBvDMNgGZJoexRQUFxrQBwdIOdJSBoNJ3R5IgSEQ/KF7uoYOh2wQULtVVIdgKwvk+sqxE66fw3rRkU0b08hni5n15ZRut2uzRohF9TwUfiN0JU960aQvCOCsKHxcpJtKecZ9UnURxGny2YAwLfWz8GWN6U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=Kz9L+s6E; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="Kz9L+s6E" Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56475L0K002484; Fri, 4 Jul 2025 07:53:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= 8ALehUfaAI4IY27cRjx8dzUmqW2nXmDiXJKkuDzIEok=; b=Kz9L+s6EhcwDnwCD 2ZF3DRiFMeBF29cJfmPMc8Dn+76WnFH+995xpk+35Cct057ogyr/W61nlmBqsxyH T7EMLu1c9TNvNKRaZKWO6/nsJJbzwuMruPXarS9gxyLbOzVOysXNHhlqDUn7mOsr jfQVtxZERdUl6efmDAb35SUXuqcMsY/A+IsOS2R7F0tVa/bcaHKTyOPpdatqo17M enj4RjKYevXh5jZeqgJLQxIMLMW9T90kWDZoJt42ttBH7zzRakipnOjWAXPbMtCQ V+l1AfhSXrN31sCGaeuOgnkP9hyHFerlzKQD+wWd+Xmdp6tWy0LJ9n4/EH5rfky2 e5fEwA== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 47j63kka0q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Jul 2025 07:53:44 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA02.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 5647rhNJ024888 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 4 Jul 2025 07:53:43 GMT Received: from hu-dikshita-hyd.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Fri, 4 Jul 2025 00:53:40 -0700 From: Dikshita Agarwal Date: Fri, 4 Jul 2025 13:23:06 +0530 Subject: [PATCH 06/25] media: iris: Allow substate transition to load resources during output streaming Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20250704-iris-video-encoder-v1-6-b6ce24e273cf@quicinc.com> References: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> In-Reply-To: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> To: Vikash Garodia , Abhinav Kumar , Bryan O'Donoghue , Mauro Carvalho Chehab , Hans Verkuil , Stefan Schmidt , "Vedang Nagar" CC: , , , Dikshita Agarwal X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1751615599; l=1376; i=quic_dikshita@quicinc.com; s=20240917; h=from:subject:message-id; bh=0Pf75v5OaEW2TsnHb7bM1RCGbkIAWKJpnd+MVuR3y7U=; b=n2OrgbwrbNHXFcbApRIZtWSmycWSWRdC4OnyzEyMF0q7b9aJjhGrFIQmWCa0hOzUYsp17vMXY RBXYjIduI2pDFE0r2wEplWYWRrGEdEoTT2st0ylglTC7VvIUCFdnR7L X-Developer-Key: i=quic_dikshita@quicinc.com; a=ed25519; pk=EEvKY6Ar1OI5SWf44FJ1Ebo1KuQEVbbf5UNPO+UHVhM= X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Authority-Analysis: v=2.4 cv=ZKfXmW7b c=1 sm=1 tr=0 ts=68678888 cx=c_pps a=JYp8KDb2vCoCEuGobkYCKw==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=GEpy-HfZoHoA:10 a=IkcTkHD0fZMA:10 a=Wb1JkmetP80A:10 a=COk6AnOGAAAA:8 a=lu2khcAHcSyz6XcsDAYA:9 a=QEXdDO2ut3YA:10 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzA0MDA2MCBTYWx0ZWRfX444EkOhyCnms zvEcMXTeZZVWG8nWDW5yrQvSVHVqRLVR652s90ykOgorz/6CzeyVBxHixGBlmacmAGKw3+03H2U Kj2wLjP8ctV/bu6AqEQSD3Lr3RF3K8qTvZwhRJjrnj1leJXMmT0yaaovgg5zjQg3babKXeh9yj3 8h/qblAvjIG7jNcB5GyyC5LPSxahRtTKeJAa1zbwL3IBFmb5Wcq1E6xKYOb9uKjKo4xm+LLk2vU y3ZdPHR4YxJLXyEWnAnfcEIMKHzDoC2KjTCoeIZw2QLaSjNSkHhvMYqDlg6XkIqa5KN1h38tGHx kY6WF7WWLp6hcarXu9NC14Djsbb0KghjQxgtY+31jEntJtYA7ZSYgSqLAzgqt8wh00ZMCiQqX5g jEK3krVerf2a8+Frv4Gda7kSevJ5i1GxNqu9GQ4tk0YRZyMgbJOXzLx+pYyEAHwQwXOLFmvE X-Proofpoint-ORIG-GUID: krqnVjy-GtfpvbwQ_Qtlf-n9QiupH2HI X-Proofpoint-GUID: krqnVjy-GtfpvbwQ_Qtlf-n9QiupH2HI X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-04_03,2025-07-02_04,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxscore=0 mlxlogscore=999 spamscore=0 suspectscore=0 bulkscore=0 priorityscore=1501 lowpriorityscore=0 phishscore=0 impostorscore=0 malwarescore=0 clxscore=1015 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507040060 Previously, the transition to load resources substate was only allowed when instance state was INIT, since capture port streaming was not permitted before output port streaming in the driver. However, now after removing that restriction, the instance state can be OUTPUT_STREAMING when firmware start is triggered and substate needs to be moved to LOAD_RESOURCES. Fixes: 547f7b8c5090 ("media: iris: add check to allow sub states transition= s") Signed-off-by: Dikshita Agarwal Reviewed-by: Vikash Garodia Tested-by: Vikash Garodia # X1E80100 --- drivers/media/platform/qcom/iris/iris_state.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/qcom/iris/iris_state.c b/drivers/media/= platform/qcom/iris/iris_state.c index 104e1687ad39dab93ff66450ba3a97c309b1e1e1..a21238d2818f9606871953bd0be= e25382cca0474 100644 --- a/drivers/media/platform/qcom/iris/iris_state.c +++ b/drivers/media/platform/qcom/iris/iris_state.c @@ -122,7 +122,8 @@ static bool iris_inst_allow_sub_state(struct iris_inst = *inst, enum iris_inst_sub return false; case IRIS_INST_OUTPUT_STREAMING: if (sub_state & (IRIS_INST_SUB_DRC_LAST | - IRIS_INST_SUB_DRAIN_LAST | IRIS_INST_SUB_OUTPUT_PAUSE)) + IRIS_INST_SUB_DRAIN_LAST | IRIS_INST_SUB_OUTPUT_PAUSE | + IRIS_INST_SUB_LOAD_RESOURCES)) return true; return false; case IRIS_INST_STREAMING: --=20 2.34.1 From nobody Tue Oct 7 22:51:46 2025 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 11480288513; Fri, 4 Jul 2025 07:53:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615634; cv=none; b=VfxoOFwS34R6Weca016yjcaVic9Ynm0901VRRJUa69ETeUZUr7VkrnwnzYaf6UMAtKG/0J0do6Wt5yVtp6BmXsbYFRF1iAhzX6iAvWBom8i7wzyyz41GrzGXVwwzLJcB2iZ4d1AE349QXgF22tgLyxevv0N5XPxzUVqWfP1/zB4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615634; c=relaxed/simple; bh=qKNLIuy3ZoF5RP+o/JvuAy3nbPtUGAGxVYj197qD6Ew=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=cE3lSLLZhNiyGeElfZp7UmDN0m7IaLJIDMZHtgCisL8hKKOI6cj+G25m2nuAwEjE9krVFThYCnXv5e0uXzfBhTYT+o3/0+KwBMCPjKQwm2WcuS1rT/NYIwlD7Drf+wE/n+MOchbDl6scBdV9SEPbq1A2yukOiPd5A8zcw3of4lw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=Js5lWSvK; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="Js5lWSvK" Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5644Ldkd000729; Fri, 4 Jul 2025 07:53:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= xuOO8TwhPY5Xa1BQRz9JYIK/SvvIW7/0oHoaOoVq7wg=; b=Js5lWSvKPOZmaeiB vXbsjcs+MCxcRQcQvg3w018VdkBUJYEcWcEgN54XHxrroXoDvHplhVIofpqlwKcC 6TgICln8QJtl+c4tk+QK68pnY7nfZYdUgGRK9mgjWlVFM1cK8q7bPhL6WKxANe8v kD8WN0uUT94inwz8zoYTT/1JG57/Ij43Ds/c0ZBY0iZsndBacCi5cYgr4uimh6dX f+E5ahyvh73DmGbxKn0QMGDksEBDSi0db1L0gKp4d3jj9CaTlnnGP+80R84M2Iuw SP4zCRMWR+IbCSuQlQ1FVi/4H49ywp7P1g83tm9gHVSUCIxlH42QK01dbddfH1m3 jPs1ig== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 47p7ut0gdh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Jul 2025 07:53:47 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA03.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 5647rlXM018886 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 4 Jul 2025 07:53:47 GMT Received: from hu-dikshita-hyd.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Fri, 4 Jul 2025 00:53:43 -0700 From: Dikshita Agarwal Date: Fri, 4 Jul 2025 13:23:07 +0530 Subject: [PATCH 07/25] media: iris: Always destroy internal buffers on firmware release response Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20250704-iris-video-encoder-v1-7-b6ce24e273cf@quicinc.com> References: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> In-Reply-To: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> To: Vikash Garodia , Abhinav Kumar , Bryan O'Donoghue , Mauro Carvalho Chehab , Hans Verkuil , Stefan Schmidt , "Vedang Nagar" CC: , , , Dikshita Agarwal X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1751615599; l=1945; i=quic_dikshita@quicinc.com; s=20240917; h=from:subject:message-id; bh=qKNLIuy3ZoF5RP+o/JvuAy3nbPtUGAGxVYj197qD6Ew=; b=1qD2MewfHHu4Gao/BCIciw1+yvi7LTPluLzqG2weut0Lhf3RFg2F1QKhyDBZ1kUOH5n36OPXu rJIXF6fPyjED0LV+z+z/H2gUzSOPVFz567SVsWynAdbUHMHpWy7gzt9 X-Developer-Key: i=quic_dikshita@quicinc.com; a=ed25519; pk=EEvKY6Ar1OI5SWf44FJ1Ebo1KuQEVbbf5UNPO+UHVhM= X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzA0MDA2MCBTYWx0ZWRfX2ETE6+JQRSb8 A+L3ckCPwX8Y/ROKfyRl9rvQLOLJWYvfnkLNB3ZzLRu6CFVToUrpHN15vdevsMuS2aNONooHC24 /mYME6PUE0aWkT1GGgtikK7GzMu34KhXsZG4c3NQGcYUgNC66lrR5o0szeD/a+DXnrKbfyZrf/j TQsWahfD8C9IuAXGkbqAG5jwV/Iibeb5tezAfxujMmIAIW70q6S3IzHtKemsMSGmIgYD+BueW0G vt/a6jAYAq6i9QJKGFB3IYn887l+CO9p6stHdDOH7cm81+fQO9CxA8jFWkXOkcqcaJ8a1PXE2Lc X1OIFHtPPKUNaoCF2a92a+eMe8qWHfEj/zDiG1887Zzx+a4mutZUvgQTeGYZ079HKKKao1sndkq QNnNU2+9VBVCPbEZzS7cRv94Xt0jX/Qw+cTydhj8jUbjXq1cLBCmZn8HB4F2R+dSwTEbvi5U X-Proofpoint-GUID: vjuuqlsIognHLNA3W2aBeYBaKxC_fgp5 X-Authority-Analysis: v=2.4 cv=Ncfm13D4 c=1 sm=1 tr=0 ts=6867888b cx=c_pps a=JYp8KDb2vCoCEuGobkYCKw==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=GEpy-HfZoHoA:10 a=IkcTkHD0fZMA:10 a=Wb1JkmetP80A:10 a=COk6AnOGAAAA:8 a=cv9jiV36alrmsoyKlDgA:9 a=QEXdDO2ut3YA:10 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-ORIG-GUID: vjuuqlsIognHLNA3W2aBeYBaKxC_fgp5 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-04_03,2025-07-02_04,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 bulkscore=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 suspectscore=0 priorityscore=1501 mlxlogscore=999 spamscore=0 malwarescore=0 adultscore=0 mlxscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507040060 Currently, internal buffers are destroyed only if 'PENDING_RELEASE' flag is set when a release response is received from the firmware, which is incorrect. Internal buffers should always be destroyed when the firmware explicitly releases it, regardless of whether the 'PENDING_RELEASE' flag was set by the driver. This is specially important during force-stop scenarios, where the firmware may release buffers without driver marking them for release. Fix this by removing the incorrect check and ensuring all buffers are properly cleaned up. Fixes: 73702f45db81 ("media: iris: allocate, initialize and queue internal = buffers") Signed-off-by: Dikshita Agarwal Reviewed-by: Vikash Garodia Tested-by: Vikash Garodia # X1E80100 --- drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c b/dr= ivers/media/platform/qcom/iris/iris_hfi_gen2_response.c index a8c30fc5c0d0668cc9980f2fcfcf21072cf9ef0a..dda775d463e916f70da0b879702= d96df18ea8bf7 100644 --- a/drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c @@ -424,7 +424,6 @@ static int iris_hfi_gen2_handle_release_internal_buffer= (struct iris_inst *inst, struct iris_buffers *buffers =3D &inst->buffers[buf_type]; struct iris_buffer *buf, *iter; bool found =3D false; - int ret =3D 0; =20 list_for_each_entry(iter, &buffers->list, list) { if (iter->device_addr =3D=3D buffer->base_address) { @@ -437,10 +436,8 @@ static int iris_hfi_gen2_handle_release_internal_buffe= r(struct iris_inst *inst, return -EINVAL; =20 buf->attr &=3D ~BUF_ATTR_QUEUED; - if (buf->attr & BUF_ATTR_PENDING_RELEASE) - ret =3D iris_destroy_internal_buffer(inst, buf); =20 - return ret; + return iris_destroy_internal_buffer(inst, buf); } =20 static int iris_hfi_gen2_handle_session_stop(struct iris_inst *inst, --=20 2.34.1 From nobody Tue Oct 7 22:51:46 2025 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 58DF7288C29; Fri, 4 Jul 2025 07:54:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615643; cv=none; b=Z3VvqdjnYsgcAzEL0EOYoDKaNtwLJtNYZlOZL/8c2uX3U8HxhtbaXHLmyXmAsKF98meuNawjXelJYJQFH5HUOZX3eZFzJmjYWa6qCHj7Oh4a1t+S4JM2+FB/Yr/QOb4kIzSlY9XYTJ/W3BjZAQcAqMp/bQs+lcuRH7UWSh34ZcA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615643; c=relaxed/simple; bh=dRxbz96Z2+jNfqLv4UxWyQRKThDSBP9Zop23bLgLf+8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=RyhBhMBblkOBFFd+g4Xfs4RqONUCCbmp1f9MfLlImKlDh5280bGuWeFNy9O3nWKjJIVGjPlgAjGvvHsIvScY5ovqqEJoChyuN2zdSUXNgQojxMLQl51nqCKjCt4XV0oYo8KjVsHeTyUHaq8ZyPZnFZy+2Zh3kQ3b66Cl0qQh3Wc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=JqaJJTln; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="JqaJJTln" Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5645w92P028430; Fri, 4 Jul 2025 07:53:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= JcVofRBfVreMJIT8Bh5XM2YdJsgL8YWro4Lt3Uj3ZfQ=; b=JqaJJTlnhQ3YEHBt ESz5HdnWSF0DlHG3Ty1junGQKWlp5O7vBVlr/FLDpjWexijrc0lUsm71STZsmC8E pdHoKK6Ldfx9zw5+mras2n3dKOzgH9mpqwWlG7wX/hhTvAEtQVwTfMkFHwCnU/Zp jh5uUL+kW3O8KqOWDRYCxB5oszcuF5vXV9htrAYDVS/JZG+G7Hc4t/SLR7LofGoT Ps45WqC5TMRSoXrgUdQgrdVY1dY28IO7xRZzvpjXOa9dTbx77M2ocLRztbopNRYY 2h0uEnxKi24niXdoZV2PcgEjDFILrYDepiI29rF/B3EEbC/SXb6i0BxXKDoBYHIh f3IR7w== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 47j7bw34s6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Jul 2025 07:53:50 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA04.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 5647roI6017939 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 4 Jul 2025 07:53:50 GMT Received: from hu-dikshita-hyd.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Fri, 4 Jul 2025 00:53:47 -0700 From: Dikshita Agarwal Date: Fri, 4 Jul 2025 13:23:08 +0530 Subject: [PATCH 08/25] media: iris: Update vbuf flags before v4l2_m2m_buf_done Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20250704-iris-video-encoder-v1-8-b6ce24e273cf@quicinc.com> References: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> In-Reply-To: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> To: Vikash Garodia , Abhinav Kumar , Bryan O'Donoghue , Mauro Carvalho Chehab , Hans Verkuil , Stefan Schmidt , "Vedang Nagar" CC: , , , Dikshita Agarwal X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1751615599; l=1365; i=quic_dikshita@quicinc.com; s=20240917; h=from:subject:message-id; bh=dRxbz96Z2+jNfqLv4UxWyQRKThDSBP9Zop23bLgLf+8=; b=+Gq3tMYKouZMTDqZhnZApgufQOYbAltLtG++wGzUjkWSeXKbPJ4X0SyvpmKhnageVwc7Rpnd+ 0+gKd5WlnafDTchxxGq8AjEFUFY2ilW71DDFkQ+EuQmrfTuEGLZGVXx X-Developer-Key: i=quic_dikshita@quicinc.com; a=ed25519; pk=EEvKY6Ar1OI5SWf44FJ1Ebo1KuQEVbbf5UNPO+UHVhM= X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: 4Nu0ZGRzqiCLVl98N0SPx4YU_UNJ4C3R X-Authority-Analysis: v=2.4 cv=RJCzH5i+ c=1 sm=1 tr=0 ts=6867888e cx=c_pps a=JYp8KDb2vCoCEuGobkYCKw==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=GEpy-HfZoHoA:10 a=IkcTkHD0fZMA:10 a=Wb1JkmetP80A:10 a=COk6AnOGAAAA:8 a=MjMrax0v_7cEApFHy6YA:9 a=QEXdDO2ut3YA:10 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-ORIG-GUID: 4Nu0ZGRzqiCLVl98N0SPx4YU_UNJ4C3R X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzA0MDA2MCBTYWx0ZWRfX/lTN4A92BqH1 bdfS45eKEV6pxxUBypj1qUR1wEQ7oQd4KlX33Ngdcy7naV3fC+R7VFTH3jR/XVm5Q47GrbIGSig t5I7L3AyONCiQXq0hfIZ4qIFgzh1BVwmvZXfs3PVY6fTmOoDALmrMenhsP/OMNC9VXe+vidR4rI 4rJ8lB7ppaZHSjLoJl5nYxQAm26hVS1O6iKOmJRHBFAAm1HsW6WR336CxrtCyAKdbyC/DUPNcNs XGh5nLkkmzlVBA1chg9+e8RYTjcf5nzYkvwFYHSp32aNadiRhN3wa96BjkZ1nUCI3q4XtLms6Qk BfCGiPaFXJoVIDlghXr0+lBEc7fRe1fn+tqOj+OcNZxV+4LEKfKSVhnLYcbLW3BZJuzl+o6pOsV QOyf1cT2FJpd2E2RMwst47W6iOx/MyA/DjgAeLGmpQmX32h74pKbdaCY972akbIXAbfomz0j X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-04_03,2025-07-02_04,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 impostorscore=0 priorityscore=1501 mlxlogscore=860 adultscore=0 malwarescore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 phishscore=0 bulkscore=0 suspectscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507040060 Update the vbuf flags appropriately in error cases before calling v4l2_m2m_buf_done(). Previously, the flag update was skippied in error scenario, which could result in incorrect state reporting for buffers. Fixes: 17f2a485ca67 ("media: iris: implement vb2 ops for buf_queue and firm= ware response") Signed-off-by: Dikshita Agarwal Reviewed-by: Vikash Garodia Tested-by: Vikash Garodia # X1E80100 --- drivers/media/platform/qcom/iris/iris_buffer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/qcom/iris/iris_buffer.c b/drivers/media= /platform/qcom/iris/iris_buffer.c index 320ebfb833331294ba5ddda8e9cd243c80633408..3ab533310b2dfece11ea31b30d2= 9ecb32e0c3f87 100644 --- a/drivers/media/platform/qcom/iris/iris_buffer.c +++ b/drivers/media/platform/qcom/iris/iris_buffer.c @@ -651,6 +651,8 @@ int iris_vb2_buffer_done(struct iris_inst *inst, struct= iris_buffer *buf) =20 vb2 =3D &vbuf->vb2_buf; =20 + vbuf->flags |=3D buf->flags; + if (buf->flags & V4L2_BUF_FLAG_ERROR) { state =3D VB2_BUF_STATE_ERROR; vb2_set_plane_payload(vb2, 0, 0); @@ -659,8 +661,6 @@ int iris_vb2_buffer_done(struct iris_inst *inst, struct= iris_buffer *buf) return 0; } =20 - vbuf->flags |=3D buf->flags; - if (V4L2_TYPE_IS_CAPTURE(type)) { vb2_set_plane_payload(vb2, 0, buf->data_size); vbuf->sequence =3D inst->sequence_cap++; --=20 2.34.1 From nobody Tue Oct 7 22:51:46 2025 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 11E64285CBD; Fri, 4 Jul 2025 07:53:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615641; cv=none; b=RUE45v+E6J8+SJNxmJh5hLIH1epQl9ZsMYYmUS1C3XN+CJxqS4MmESc45UrbnIMxjBXWlyjPeGH2j314P/eUQy41p29SmSTs1DdRcoSsFjzjkd6lJUlcSHof8AgTXzi5JCSbyYbTFDXLQATw1nhSgGYfsoYKJo2LnKzPAdEryLA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615641; c=relaxed/simple; bh=nXe1rAWwt0e1F6ohnI+QMUnmDrfMRCDDVmIn0JOu1dM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=BlPs4bhy7iMfDDo4lnaYVUlciTKpaO35ghtLGqsCFIjk77An0B0F9ILLj9uWs/H8OrJkfqiTnP0MOa+coXGVw6kUV3pu1ayD+DIHdlVZVXjfWrR8xvru37xWY5uaQ3hfzIq4mv2FimiA7yXHRakjVp9Ycz3hmyVkxDWlr8//S7A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=flGhEYgv; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="flGhEYgv" Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56472Plv032116; Fri, 4 Jul 2025 07:53:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= 1BpenVzgD1MUrMTGT+k2H48hWJXx+AEI8C5ji57G8lk=; b=flGhEYgvmljqy7QU CAx6V1HugQcsfKVz+QAQy6ICS4oSwn56In4qqVWTE39tQxfJiaOHY3j+h1+IcN6v fChtrj+A34VhyXKfHxDsQfN/uQ6lpe4rt6lG/be2Z2jR9YUB4MasyA/DOUtZshTM gSpTI7IOEW8yBsR0VyAF6Z5WHDeNDq31cmsPGRpP6JB3rHE4c7u1yw1o2lqdMi7p XW9hzaczGY8u+hZ3OCaZwbYwIuqAdFCUgw0YrG6VCkE486jcC4E+1+zyXFE/a4Mz DRol7oU9U1D4RMxBCROim7z2NvmihhDCTTKBBgW5WzOq5T8TG/UWpcDmyLfZISPj hoOUag== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 47j63kka16-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Jul 2025 07:53:54 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA04.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 5647rrYK017981 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 4 Jul 2025 07:53:53 GMT Received: from hu-dikshita-hyd.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Fri, 4 Jul 2025 00:53:50 -0700 From: Dikshita Agarwal Date: Fri, 4 Jul 2025 13:23:09 +0530 Subject: [PATCH 09/25] media: iris: Allow stop on firmware only if start was issued. Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20250704-iris-video-encoder-v1-9-b6ce24e273cf@quicinc.com> References: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> In-Reply-To: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> To: Vikash Garodia , Abhinav Kumar , Bryan O'Donoghue , Mauro Carvalho Chehab , Hans Verkuil , Stefan Schmidt , "Vedang Nagar" CC: , , , Dikshita Agarwal X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1751615599; l=1668; i=quic_dikshita@quicinc.com; s=20240917; h=from:subject:message-id; bh=nXe1rAWwt0e1F6ohnI+QMUnmDrfMRCDDVmIn0JOu1dM=; b=4G9PDDDwAR8a02ZWjfDkk7Sp7Eqiwov3JfHErbnu7li9ksXXEd6h6dKYRP1oKYHBWKfvTJAS9 LLu4AmNHxiGDvOZ00RT4LGJ/OoDD/HbnLf58sFuw6Scb9MRMUeVXfTB X-Developer-Key: i=quic_dikshita@quicinc.com; a=ed25519; pk=EEvKY6Ar1OI5SWf44FJ1Ebo1KuQEVbbf5UNPO+UHVhM= X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Authority-Analysis: v=2.4 cv=ZKfXmW7b c=1 sm=1 tr=0 ts=68678892 cx=c_pps a=JYp8KDb2vCoCEuGobkYCKw==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=GEpy-HfZoHoA:10 a=IkcTkHD0fZMA:10 a=Wb1JkmetP80A:10 a=COk6AnOGAAAA:8 a=rsWgEMF2Pf62jCDWMwkA:9 a=QEXdDO2ut3YA:10 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzA0MDA2MCBTYWx0ZWRfXyH4sOy5olELH hOa9w/pE7VwtFtEhSG24h/ADjFMNx3wekrU0PTm3a8lSbuoXIRj6xYxMg0/FM3vxd29Q1eYJROl HnKS4JuGt2CrVR7AH5uFluza3F6UyNLgrf53Fps4HNT7Y6KkNwWHbfsPps0tPe9eBtq3WVEjAOy PiDJunatWb0Zgwr0Q1VptiG4G63IRKHBlubrroOHkRncXqs3QgToGPkqfxGLB8RAXOqCfk4J42t dF0Bj3LflY0WXJ8ZHU9ipPzbUx75la3mGnJ5gjQFpo3Q/gHbODkWyPJmuT79j9llOoHKg8mJiX0 YLa9LQ1TKoV5yZRr3aC93mx+0vm72ZnUT/KZf0vmTF7/P+cOLDAna6Hg4VrQsj0zszSOHcOcjmN h+4uloi4iI4Jm5KsiSfl1JCb4EyLJ0dlDBQ0DJ7wCe3ZFINCmcdu9UwAygN+P0n+Ka9KkcAg X-Proofpoint-ORIG-GUID: vLqv6kExfJeBVv4zlZZayORrMyx5uD2r X-Proofpoint-GUID: vLqv6kExfJeBVv4zlZZayORrMyx5uD2r X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-04_03,2025-07-02_04,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxscore=0 mlxlogscore=916 spamscore=0 suspectscore=0 bulkscore=0 priorityscore=1501 lowpriorityscore=0 phishscore=0 impostorscore=0 malwarescore=0 clxscore=1015 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507040060 For HFI Gen1, the instances substate is changed to LOAD_RESOURCES only when a START command is issues to the firmware. If STOP is called without a prior START, the firmware may reject the command and throw some erros. Handle this by adding a substate check before issuing STOP command to the firmware. Fixes: 11712ce70f8e ("media: iris: implement vb2 streaming ops") Signed-off-by: Dikshita Agarwal Reviewed-by: Vikash Garodia Tested-by: Vikash Garodia # X1E80100 --- drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c b/dri= vers/media/platform/qcom/iris/iris_hfi_gen1_command.c index 5fc30d54af4dc34616cfd08813940aa0b7044a20..5f1748ab80f88393215fc2d82c5= c6b4af1266090 100644 --- a/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c @@ -184,11 +184,12 @@ static int iris_hfi_gen1_session_stop(struct iris_ins= t *inst, u32 plane) u32 flush_type =3D 0; int ret =3D 0; =20 - if ((V4L2_TYPE_IS_OUTPUT(plane) && - inst->state =3D=3D IRIS_INST_INPUT_STREAMING) || + if (((V4L2_TYPE_IS_OUTPUT(plane) && + inst->state =3D=3D IRIS_INST_INPUT_STREAMING) || (V4L2_TYPE_IS_CAPTURE(plane) && inst->state =3D=3D IRIS_INST_OUTPUT_STREAMING) || - inst->state =3D=3D IRIS_INST_ERROR) { + inst->state =3D=3D IRIS_INST_ERROR) && + inst->sub_state & IRIS_INST_SUB_LOAD_RESOURCES) { reinit_completion(&inst->completion); iris_hfi_gen1_packet_session_cmd(inst, &pkt, HFI_CMD_SESSION_STOP); ret =3D iris_hfi_queue_cmd_write(core, &pkt, pkt.shdr.hdr.size); --=20 2.34.1 From nobody Tue Oct 7 22:51:46 2025 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 17829288C8F; Fri, 4 Jul 2025 07:54:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615645; cv=none; b=kktwMOLsP7gnP0gzHH4XZyY0fzx+NkyLOM+OpYiZavr80Hi9/1Nvj4SxqT7YQHm37hMr95SbpmPchMOYepsdo3mzROcH0e2RZLv5AvyUWEieZ+wJzLBIpKUuoEJtT/WJha/xoEHpOWouvskIgg21XIb6v2mszdXj4ap1BNFV640= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615645; c=relaxed/simple; bh=9sgrDBDt6l/8nblPznn01M3b9Hq+ziVBP/+mB5n2VUI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=i6VwTKiD1pEUy9UrSW8A/IOaX5eMTr2IVa9azxDShFbY5atgMF8/zAZzXGu9JZRnT3zSXoIrHyyVBVGhC8RCPufuLGAyDI3EMCeE9L/4U6GIZ/+/CuBzeDQ6Q39oVaXzCDEu6HJgPDMpfFxurSOWsMnVZvBgOefcQmyVjIm4A4k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=lZXbJbgW; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="lZXbJbgW" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 563JPJc6029542; Fri, 4 Jul 2025 07:53:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= rZ9nWVQW0Uu8adQyey2qqf18o2DXaVid4arZvYDvmPc=; b=lZXbJbgWfLv6KgYH kUpQd6lRdFpBM5zK+goIBG0mQXEeUFIe20StIskSaf4Shw4bbre4INID+CjumCNB YJajbpncic1+WP2bsOlz35djKHisADQCfyladqZ+sX/WFK3OWHF3e3ZEmAxuXyRE HMdkdjVo8d51Kg33uLIA8JU6J+4iAgM0YBldiucZesOM1+1VjPkDz3DMAYilFzwF IIPpZCtxT2Zv4Ushe+nQifIvFkuBTpGuYeQHDSe7uaWieBbG4DfsU70QeMSE3KfC hFAi9Y+V2Q8hGvVm76ICpk2kpPiA4eaSg1Yk3Kwg7X98gwVTcXqO7NOq1R2g2tcw 5QvvdQ== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 47nh9s4bqw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Jul 2025 07:53:59 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA01.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 5647rw4G001317 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 4 Jul 2025 07:53:58 GMT Received: from hu-dikshita-hyd.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Fri, 4 Jul 2025 00:53:53 -0700 From: Dikshita Agarwal Date: Fri, 4 Jul 2025 13:23:10 +0530 Subject: [PATCH 10/25] media: iris: Send dummy buffer address for all codecs during drain Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20250704-iris-video-encoder-v1-10-b6ce24e273cf@quicinc.com> References: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> In-Reply-To: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> To: Vikash Garodia , Abhinav Kumar , Bryan O'Donoghue , Mauro Carvalho Chehab , Hans Verkuil , Stefan Schmidt , "Vedang Nagar" CC: , , , Dikshita Agarwal X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1751615599; l=1360; i=quic_dikshita@quicinc.com; s=20240917; h=from:subject:message-id; bh=9sgrDBDt6l/8nblPznn01M3b9Hq+ziVBP/+mB5n2VUI=; b=8gdEqX3ioLbGIwAo0ImHMaulSmHJUsHiDJa11+REZswR7rQEt3YCd3hSomC32+fjsknaYS6hk 15kySHUSWh7B9HIWvwnBf78npElmrn+u1+f41u+PvUZ+il5lCyMIqII X-Developer-Key: i=quic_dikshita@quicinc.com; a=ed25519; pk=EEvKY6Ar1OI5SWf44FJ1Ebo1KuQEVbbf5UNPO+UHVhM= X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Authority-Analysis: v=2.4 cv=frrcZE4f c=1 sm=1 tr=0 ts=68678897 cx=c_pps a=JYp8KDb2vCoCEuGobkYCKw==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=GEpy-HfZoHoA:10 a=IkcTkHD0fZMA:10 a=Wb1JkmetP80A:10 a=COk6AnOGAAAA:8 a=9ca8n8zwjEs3-HHftV8A:9 a=QEXdDO2ut3YA:10 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzA0MDA2MCBTYWx0ZWRfX2XEYUgSthNa3 f0HW2y49pttzFW2RkH8ZjmLpB5s2IdDvdp8v9LOAzmKHPpwtitC67+rKHd9wJK13ctSQNAoSIEX RINYpBcyYlLUMx4r2m/bluwxhZR140WOJqfEHQGg7KyXQ/UECjixTZVoLPX/bSuWc/EmXGq0d/p YdmaumEczfTYQwLBO6wJe2uO/GJSQCu/PAMvVcqOTA8BwH4poUMKiAJUh943qT6mVWatQ/Te8qG znRHINsYiBeNMCHL/QWUBzZ91/srxfxvHhDLKvMIXe+tfx1mNPtYRshCmRb6jGrLKLcrfQHSTUW UlUi910RNKlQqzYycB7C3JQxW2feFRYGilbXo3aF8MYJmvKkO0OtX124bw2F//v3gMPEn1OcV1Q 1fC2Y6rVvfKl752722ugpCDiltjCThS/qCnakvzmhq4bUwgC2UaBJdLiVd8hUegncq02+ZTa X-Proofpoint-GUID: ZcyaU_NlAGAQ185LjZaP4i5b5AFTX_LM X-Proofpoint-ORIG-GUID: ZcyaU_NlAGAQ185LjZaP4i5b5AFTX_LM X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-04_03,2025-07-02_04,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxlogscore=999 bulkscore=0 spamscore=0 adultscore=0 impostorscore=0 clxscore=1015 lowpriorityscore=0 suspectscore=0 mlxscore=0 priorityscore=1501 malwarescore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507040060 Firmware can handle a dummy address for buffers with the EOS flag. To ensure consistent behavior across all codecs, update the drain command to always send a dummy buffer address. This makes the drain handling uniform and avoids any codec specific assumptions. Fixes: 478c4478610d ("media: iris: Add codec specific check for VP9 decoder= drain handling") Signed-off-by: Dikshita Agarwal Reviewed-by: Vikash Garodia Tested-by: Vikash Garodia # X1E80100 --- drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c b/dri= vers/media/platform/qcom/iris/iris_hfi_gen1_command.c index 5f1748ab80f88393215fc2d82c5c6b4af1266090..5097680ee14ebba3a126213c058= 4161627ca47d7 100644 --- a/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c @@ -402,8 +402,7 @@ static int iris_hfi_gen1_session_drain(struct iris_inst= *inst, u32 plane) ip_pkt.shdr.hdr.pkt_type =3D HFI_CMD_SESSION_EMPTY_BUFFER; ip_pkt.shdr.session_id =3D inst->session_id; ip_pkt.flags =3D HFI_BUFFERFLAG_EOS; - if (inst->codec =3D=3D V4L2_PIX_FMT_VP9) - ip_pkt.packet_buffer =3D 0xdeadb000; + ip_pkt.packet_buffer =3D 0xdeadb000; =20 return iris_hfi_queue_cmd_write(inst->core, &ip_pkt, ip_pkt.shdr.hdr.size= ); } --=20 2.34.1 From nobody Tue Oct 7 22:51:46 2025 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 6FF4F28AB16; Fri, 4 Jul 2025 07:54:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615649; cv=none; b=oI+iINrPL8sxtxe8mx0buXfxGJeaUngZMrV1fA3KD9ldZHEU0qZijVsmJUjo1GPcBM/EJ9rX+r/Fs4tGZLnoDNeNZekuO8l4cTwimfY3IfnYr5TIYH1cYqDepQdFsEYJLnP9q8Y/Leda3O8o9LMgrSTVXUSZC3uoSNI3cavgxE8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615649; c=relaxed/simple; bh=D4x384VXlugvbni5awmY75Cf1E6v+I4GeafLdEKYsw8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=Gt5v0rTQJr/GFmrEph7+rcP7yMQhg1t9A4l8+uNyw00yYU58mNbzI4waOYpXpTB4lrT0bJKQgJvDjRytheHSUfxLmxiKZnThsqc+b0cQulY+6SiefXhfdzn7QIGBXR/s7vymjbeLU8rkyPXjS7tVmQBnHOW4oP8cYXfCeEoiIyQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=Zpm4TB+h; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="Zpm4TB+h" Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5644i1L4011767; Fri, 4 Jul 2025 07:54:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= 3JtYz2Tu8uhgCnpHpQKquAp3Iq6xq1lfS4KjUL/esS8=; b=Zpm4TB+hSD0Sgwyz Lk+F6m4D//U75Xf6TxYnhlUlC9GNw/lPPIfy9oRMfaPM4i+PsxoYTaEEpiJZ/ziV mO6hXpEolrDRyRwSpILwRsg7cGO7iYfC7G5S0XQWLwgPgnshJpzd8cI0KOowdt/v VgurAmzN2TPXYXK8C/lCcnyYtYQN8GLLWUpuSqKEVykZ3aaqm8NZWxSQaOr2lbes jlUWMDcD6bEg5wAo178Ks1UG+Xb0472KEiqp6eGKYp8mnXE9oF5ocecRA3x9rLbw vFWPqcHHp8d9YFAqRBuQmPYyjGwLAwJFqZxU9FV5BFQOBQp4tRYUMZFlOoPSzzw4 6f+8bw== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 47mw30g2vj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Jul 2025 07:54:01 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA03.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 5647s0r0019179 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 4 Jul 2025 07:54:00 GMT Received: from hu-dikshita-hyd.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Fri, 4 Jul 2025 00:53:57 -0700 From: Dikshita Agarwal Date: Fri, 4 Jul 2025 13:23:11 +0530 Subject: [PATCH 11/25] media: iris: Fix missing LAST flag handling during drain Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20250704-iris-video-encoder-v1-11-b6ce24e273cf@quicinc.com> References: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> In-Reply-To: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> To: Vikash Garodia , Abhinav Kumar , Bryan O'Donoghue , Mauro Carvalho Chehab , Hans Verkuil , Stefan Schmidt , "Vedang Nagar" CC: , , , Dikshita Agarwal X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1751615599; l=3280; i=quic_dikshita@quicinc.com; s=20240917; h=from:subject:message-id; bh=D4x384VXlugvbni5awmY75Cf1E6v+I4GeafLdEKYsw8=; b=MBwW9tp7DX3Gjrjf8euMclzkV12V46TBKKQBv78yuvB61sQupuFuYh5XZMCXLH0LNoDm5Ih0Y QcLRngy2LtiD+wpTDvZ+qCofkKerwn2g+ClBxKsTgawjLHyYERIGtTp X-Developer-Key: i=quic_dikshita@quicinc.com; a=ed25519; pk=EEvKY6Ar1OI5SWf44FJ1Ebo1KuQEVbbf5UNPO+UHVhM= X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Authority-Analysis: v=2.4 cv=CY4I5Krl c=1 sm=1 tr=0 ts=68678899 cx=c_pps a=JYp8KDb2vCoCEuGobkYCKw==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=GEpy-HfZoHoA:10 a=IkcTkHD0fZMA:10 a=Wb1JkmetP80A:10 a=COk6AnOGAAAA:8 a=0wdjZXPW0me86wH4VXQA:9 a=QEXdDO2ut3YA:10 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-ORIG-GUID: pDVsbkU0ZRo30hQ7hqFT6E0FWxZ-nxsT X-Proofpoint-GUID: pDVsbkU0ZRo30hQ7hqFT6E0FWxZ-nxsT X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzA0MDA2MCBTYWx0ZWRfX44NUaXrWOhvk Ocv4AJe50dgpq2CLF7vNYqXpTdK08Uz5miKY3uCUFn/Bc422izeu2LwA+zKDSaY3T2IzYcY4jpH KlLacGv/NtnI0ghB3seKn1mQ1W1lIbLMuCSN105iRTRI7O4zK/HCIjNOId+2Y27Z4OPvyDnJ4AC +F2mc9WuLXZ+riuIm82xoQ48CTQhzBxtMJ5Deif6gpOGLOD+XdBdntMqikW6GagOFDhgfiEfx5I CvvumrmpVMq5QLpbmff874o3wK7J74f1UJk0yLH8+qWYhsYi23cRbBYEGm4tCXKs46x5ZcjjVza v/hWDzU33mAfh/m5Y/y3s61TEK74Xegwhd9tjSQRPBKLZaVYCFVAYj07FkJjo6jwsx6bgNYZUwD Ht8PtIqKEsoSFqMALquYvAMrOVutxwE2UNrAofBuIpog9Z1t139NbP+SZwu3oMVa6+kgdH2t X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-04_03,2025-07-02_04,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxlogscore=655 priorityscore=1501 clxscore=1015 lowpriorityscore=0 mlxscore=0 phishscore=0 suspectscore=0 bulkscore=0 malwarescore=0 impostorscore=0 spamscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507040060 Improve drain handling by ensuring the LAST flag is attached to final capture buffer when drain response is received from the firmware. Previously, the driver failed to attach the V4L2_BUF_FLAG_LAST flag when a drain response was received from the firmware, relying on userspace to mark the next queued buffer as LAST. This update fixes the issue by checking the pending drain status, attaching the LAST flag to the capture buffer received from the firmware (with EOS attached), and returning it to the V4L2 layer correctly. Fixes: d09100763bed ("media: iris: add support for drain sequence") Signed-off-by: Dikshita Agarwal Reviewed-by: Vikash Garodia Tested-by: Vikash Garodia # X1E80100 --- drivers/media/platform/qcom/iris/iris_hfi_gen1_response.c | 4 +--- drivers/media/platform/qcom/iris/iris_state.c | 2 +- drivers/media/platform/qcom/iris/iris_state.h | 1 + 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen1_response.c b/dr= ivers/media/platform/qcom/iris/iris_hfi_gen1_response.c index 8d1ce8a19a45ebb2b29457e0fef7d72c1c0d9785..2a96458833835422d30c9386d15= cc1e4fb226e3d 100644 --- a/drivers/media/platform/qcom/iris/iris_hfi_gen1_response.c +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen1_response.c @@ -416,8 +416,6 @@ static void iris_hfi_gen1_session_ftb_done(struct iris_= inst *inst, void *packet) inst->flush_responses_pending++; =20 iris_inst_sub_state_change_drain_last(inst); - - return; } =20 if (iris_split_mode_enabled(inst) && pkt->stream_id =3D=3D 0) { @@ -462,7 +460,7 @@ static void iris_hfi_gen1_session_ftb_done(struct iris_= inst *inst, void *packet) timestamp_us =3D (timestamp_us << 32) | timestamp_lo; } else { if (pkt->stream_id =3D=3D 1 && !inst->last_buffer_dequeued) { - if (iris_drc_pending(inst)) { + if (iris_drc_pending(inst) || iris_drain_pending(inst)) { flags |=3D V4L2_BUF_FLAG_LAST; inst->last_buffer_dequeued =3D true; } diff --git a/drivers/media/platform/qcom/iris/iris_state.c b/drivers/media/= platform/qcom/iris/iris_state.c index a21238d2818f9606871953bd0bee25382cca0474..d1dc1a863da0b0b1af60974e9ed= 2ef68ea225cdd 100644 --- a/drivers/media/platform/qcom/iris/iris_state.c +++ b/drivers/media/platform/qcom/iris/iris_state.c @@ -252,7 +252,7 @@ bool iris_drc_pending(struct iris_inst *inst) inst->sub_state & IRIS_INST_SUB_DRC_LAST; } =20 -static inline bool iris_drain_pending(struct iris_inst *inst) +bool iris_drain_pending(struct iris_inst *inst) { return inst->sub_state & IRIS_INST_SUB_DRAIN && inst->sub_state & IRIS_INST_SUB_DRAIN_LAST; diff --git a/drivers/media/platform/qcom/iris/iris_state.h b/drivers/media/= platform/qcom/iris/iris_state.h index e718386dbe0402417f408d8fc696a33e5c7f23b3..b09fa54cf17eeee0c9ae2545889= 64ad959c82c80 100644 --- a/drivers/media/platform/qcom/iris/iris_state.h +++ b/drivers/media/platform/qcom/iris/iris_state.h @@ -141,5 +141,6 @@ int iris_inst_sub_state_change_drc_last(struct iris_ins= t *inst); int iris_inst_sub_state_change_pause(struct iris_inst *inst, u32 plane); bool iris_allow_cmd(struct iris_inst *inst, u32 cmd); bool iris_drc_pending(struct iris_inst *inst); +bool iris_drain_pending(struct iris_inst *inst); =20 #endif --=20 2.34.1 From nobody Tue Oct 7 22:51:46 2025 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 893BC28B3ED; Fri, 4 Jul 2025 07:54:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615651; cv=none; b=SfopQYf0JyMZU+9AHYmU0/oKon/jqTc0JCxqiRNLd+ksI6YVbRv2dzg0ACC1t2zWObdEcimt0xeu5VnoZPmOc5pIPA8Uq2oTeqqhaAbQ6nUVLzzHVGbp9xRFO6JKkF2DRdcsCuekPz2WJhRd3ZomnKjCmmWXZIWjP1uijRtkq0s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615651; c=relaxed/simple; bh=HW/7bQDz6RN1kDmyJ95OWFrRONwb+HcZP7enCpgPaNA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=elSoq5fU9YVUC1PrCdZvngNCpoy+X/w4bsQoUGk0M/+5p2IcjJGw6xCAy3wkreM4qUZJLRPE6+JdD1k/XNXxQO3pOTuyvxNlyUYy+63BySSrxYK2DktPkaYUxFFVhMW0el4vxTmuHuAzMnFHWeH19UFtSkqupqHfO6/sVq+GN30= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=k9wZXyrI; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="k9wZXyrI" Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5644MtWc002481; Fri, 4 Jul 2025 07:54:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= +eG0mVfcfmUzuEgbSciyUwrRIEdvISJ0vd2Smn12H4c=; b=k9wZXyrIKZTeoqrq NOOL2OTUZqijC+5CVT3++VOr7JF7NrnlAgvjTGJtpwuO+ZYW4YTX1g/RwPFDsT53 aZnJABUH7Jk00Tkc0MDBdBJwwr+hcAz6LOIhrC2Kjd6WfVYGAk2WXcntLQmZw5wY pbHTgCfeGqRqJzV0wCOvHjLTWOBVp2t/wJF9Bzxc8szrhqjJ+QjVBsFAy3forYwc skvqqD1mTsH1lTVneYcZWc71NJbt86xBOmkCRn1rihTxOOtrgcNjswcywVjZGYD4 63wjzTilA6y6Fifm8P43Z9VOwwmGez5umb68rrX1f5IrWbybenXMxLyVSqnpGNRX hKUyuQ== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 47p7ut0gej-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Jul 2025 07:54:04 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA03.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 5647s3dG019355 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 4 Jul 2025 07:54:03 GMT Received: from hu-dikshita-hyd.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Fri, 4 Jul 2025 00:54:00 -0700 From: Dikshita Agarwal Date: Fri, 4 Jul 2025 13:23:12 +0530 Subject: [PATCH 12/25] media: iris: Add support for video encoder device Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20250704-iris-video-encoder-v1-12-b6ce24e273cf@quicinc.com> References: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> In-Reply-To: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> To: Vikash Garodia , Abhinav Kumar , Bryan O'Donoghue , Mauro Carvalho Chehab , Hans Verkuil , Stefan Schmidt , "Vedang Nagar" CC: , , , Dikshita Agarwal X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1751615599; l=4819; i=quic_dikshita@quicinc.com; s=20240917; h=from:subject:message-id; bh=HW/7bQDz6RN1kDmyJ95OWFrRONwb+HcZP7enCpgPaNA=; b=cKF3RZjeVhgpLIPR/VuHtBoctIUncjVt8fmfOzFPKCiVfoXWr/Hg92nNyt2NlfcvOM/ZrGFoQ 1yQmHceVnhNAT5yT8nq70Bj13hrKX8/HA0oXmL7weFeWkhhXCtwOHSs X-Developer-Key: i=quic_dikshita@quicinc.com; a=ed25519; pk=EEvKY6Ar1OI5SWf44FJ1Ebo1KuQEVbbf5UNPO+UHVhM= X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzA0MDA2MCBTYWx0ZWRfXxIVfCU0/3CDj 3Mu3j+TAo5WMcgmlU9oS1AAKzpl6rP/8ZmrBVInSrYHmHeS7neVIk2Gili3QRQjSNPFS0Zpd4j0 gOuvJOnZJr4paQ2HW5HbQWlynF2PuUdhgV/cKWenxqIBVuwm21sesTrx7/v6/4OQgHd47YJ+WdK zEvP6YHceF93Ok+IyBO4VWstWzTBuFOfOld/g8dCTu4L9LzUxVzRxCu8dt8rcjjIdvdZe2pwUNR LLYHtNp5Fi57SEenpBIFj5Hx4zDsjoqmcv7/UHGNA/IpbC9/qqMpzvgayjVjJh1+a/DQJViTcqR voYhJnswZOhIL0ycy4Loyk1bczhEXc1qR1BMjPlpyDOiXn/HyStmvqvter3TN8XpD3gtEdfy2Jn esmL/LG6o8+hPJku2kiOIKinvMXWYasedZpwq4FeCWfy2TBV1NiPQ9dg0iegd2KTnwUlGsDj X-Proofpoint-GUID: z9YUuieJMSrq9v3un4E9jwnhslTL_8zm X-Authority-Analysis: v=2.4 cv=Ncfm13D4 c=1 sm=1 tr=0 ts=6867889c cx=c_pps a=JYp8KDb2vCoCEuGobkYCKw==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=GEpy-HfZoHoA:10 a=IkcTkHD0fZMA:10 a=Wb1JkmetP80A:10 a=COk6AnOGAAAA:8 a=2mCIi3ssoROZVgXUOfUA:9 a=QEXdDO2ut3YA:10 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-ORIG-GUID: z9YUuieJMSrq9v3un4E9jwnhslTL_8zm X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-04_03,2025-07-02_04,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 bulkscore=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 suspectscore=0 priorityscore=1501 mlxlogscore=999 spamscore=0 malwarescore=0 adultscore=0 mlxscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507040060 Add support for registering a V4L2 encoder video device to the iris driver. The encoder device is registered with the name "qcom-iris-encoder". Signed-off-by: Dikshita Agarwal Tested-by: Vikash Garodia # X1E80100 --- drivers/media/platform/qcom/iris/iris_core.h | 7 ++++++ drivers/media/platform/qcom/iris/iris_probe.c | 36 ++++++++++++++++++++---= ---- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/drivers/media/platform/qcom/iris/iris_core.h b/drivers/media/p= latform/qcom/iris/iris_core.h index aeeac32a1f6d9a9fa7027e8e3db4d95f021c552e..09e83be4e00efb456b7098a499b= 6cce850134a06 100644 --- a/drivers/media/platform/qcom/iris/iris_core.h +++ b/drivers/media/platform/qcom/iris/iris_core.h @@ -25,6 +25,11 @@ struct icc_info { #define IRIS_FW_VERSION_LENGTH 128 #define IFACEQ_CORE_PKT_SIZE (1024 * 4) =20 +enum domain_type { + ENCODER =3D BIT(0), + DECODER =3D BIT(1), +}; + /** * struct iris_core - holds core parameters valid for all instances * @@ -33,6 +38,7 @@ struct icc_info { * @irq: iris irq * @v4l2_dev: a holder for v4l2 device structure * @vdev_dec: iris video device structure for decoder + * @vdev_enc: iris video device structure for encoder * @iris_v4l2_file_ops: iris v4l2 file ops * @iris_v4l2_ioctl_ops: iris v4l2 ioctl ops * @iris_vb2_ops: iris vb2 ops @@ -73,6 +79,7 @@ struct iris_core { int irq; struct v4l2_device v4l2_dev; struct video_device *vdev_dec; + struct video_device *vdev_enc; const struct v4l2_file_operations *iris_v4l2_file_ops; const struct v4l2_ioctl_ops *iris_v4l2_ioctl_ops; const struct vb2_ops *iris_vb2_ops; diff --git a/drivers/media/platform/qcom/iris/iris_probe.c b/drivers/media/= platform/qcom/iris/iris_probe.c index 4e6e92357968d7419f114cc0ffa9b571bad19e46..c3be9deb0a57cc2cf25d69784d5= 4be5e4a5fe06c 100644 --- a/drivers/media/platform/qcom/iris/iris_probe.c +++ b/drivers/media/platform/qcom/iris/iris_probe.c @@ -146,7 +146,7 @@ static int iris_init_resources(struct iris_core *core) return iris_init_resets(core); } =20 -static int iris_register_video_device(struct iris_core *core) +static int iris_register_video_device(struct iris_core *core, enum domain_= type type) { struct video_device *vdev; int ret; @@ -155,7 +155,6 @@ static int iris_register_video_device(struct iris_core = *core) if (!vdev) return -ENOMEM; =20 - strscpy(vdev->name, "qcom-iris-decoder", sizeof(vdev->name)); vdev->release =3D video_device_release; vdev->fops =3D core->iris_v4l2_file_ops; vdev->ioctl_ops =3D core->iris_v4l2_ioctl_ops; @@ -163,11 +162,23 @@ static int iris_register_video_device(struct iris_cor= e *core) vdev->v4l2_dev =3D &core->v4l2_dev; vdev->device_caps =3D V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_STREAMING; =20 - ret =3D video_register_device(vdev, VFL_TYPE_VIDEO, -1); - if (ret) + if (type =3D=3D DECODER) { + strscpy(vdev->name, "qcom-iris-decoder", sizeof(vdev->name)); + ret =3D video_register_device(vdev, VFL_TYPE_VIDEO, -1); + if (ret) + goto err_vdev_release; + core->vdev_dec =3D vdev; + } else if (type =3D=3D ENCODER) { + strscpy(vdev->name, "qcom-iris-encoder", sizeof(vdev->name)); + ret =3D video_register_device(vdev, VFL_TYPE_VIDEO, -1); + if (ret) + goto err_vdev_release; + core->vdev_enc =3D vdev; + } else { + ret =3D -EINVAL; goto err_vdev_release; + } =20 - core->vdev_dec =3D vdev; video_set_drvdata(vdev, core); =20 return 0; @@ -189,6 +200,7 @@ static void iris_remove(struct platform_device *pdev) iris_core_deinit(core); =20 video_unregister_device(core->vdev_dec); + video_unregister_device(core->vdev_enc); =20 v4l2_device_unregister(&core->v4l2_dev); =20 @@ -258,17 +270,21 @@ static int iris_probe(struct platform_device *pdev) if (ret) return ret; =20 - ret =3D iris_register_video_device(core); + ret =3D iris_register_video_device(core, DECODER); if (ret) goto err_v4l2_unreg; =20 + ret =3D iris_register_video_device(core, ENCODER); + if (ret) + goto err_vdev_unreg_dec; + platform_set_drvdata(pdev, core); =20 dma_mask =3D core->iris_platform_data->dma_mask; =20 ret =3D dma_set_mask_and_coherent(dev, dma_mask); if (ret) - goto err_vdev_unreg; + goto err_vdev_unreg_enc; =20 dma_set_max_seg_size(&pdev->dev, DMA_BIT_MASK(32)); dma_set_seg_boundary(&pdev->dev, DMA_BIT_MASK(32)); @@ -277,11 +293,13 @@ static int iris_probe(struct platform_device *pdev) pm_runtime_use_autosuspend(core->dev); ret =3D devm_pm_runtime_enable(core->dev); if (ret) - goto err_vdev_unreg; + goto err_vdev_unreg_enc; =20 return 0; =20 -err_vdev_unreg: +err_vdev_unreg_enc: + video_unregister_device(core->vdev_enc); +err_vdev_unreg_dec: video_unregister_device(core->vdev_dec); err_v4l2_unreg: v4l2_device_unregister(&core->v4l2_dev); --=20 2.34.1 From nobody Tue Oct 7 22:51:46 2025 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 356A329A9E6; Fri, 4 Jul 2025 07:54:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615656; cv=none; b=Lggsyn0XDJcWsy8+CnOCREkFIXrxTNLL5HHj9Y/b0AWjqSMgDHcY+N+kCOE5/1S/Y3QdSdThS1iCJoaFo9Qd97pWO7QKnDrrKdF6K7HOr8TtUbKLjLeUh4/s4vcmKnthcdxxLM+u+qMd9NpjJEpjSVjBm+pcLsR2ImF4TOW7uKQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615656; c=relaxed/simple; bh=TAtnf+/wWALLIC+DL+tLut/Gn9jkjaNVSOFRREnovH8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=CTf1G0NWVGPcEvl6xSJYFUp6MYx2CvJG0z8bX46DxKjhuzyBsY/+cH0v7swX66YXm2yNfmcJncacGHBMMeqEhXxiQZ3O33VlKZTRPW/LyNFzA6BOGyEew2xYd5gvIGgOB4yETrsG//6vaIf7k2+YRyj/stnUK77YwNQDmHe9tVg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=U/yII1/8; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="U/yII1/8" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5646QQuk008123; Fri, 4 Jul 2025 07:54:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= ii2bBmb+kZESgPV/tPBtnYXg/TO5gBi3XmvEGDQjzAk=; b=U/yII1/8WK+WEIHl o/Y5KsyhpabO0Ury3skDV0Ff/wup/d04N5y8KwWOwJpJxTI0Kq7Tvz1ga7q/oUwb +X3OlXlC/cT5TpMqjrd8UoAO+dhIhTHM0Fk8XQQjrrSb6+MEjHyo9Q5QgPwjw5pR EsJnjiHlLjW1AkYY0mwOFvfdH4kjnJcN2B1mkgLpQfzFoFq1W5bGfIq9rTYLI/eG xMcaw4JPM/47OgwYM7mzkHNehW0uPxAK7notrAYiurB2EfLZanIA3/XQEDUbsF0Q 1JoziJLAXHI2p7Amf3nVvUNyj0kZlWYqH79yMEsvQAPXnL/je7jPT8joJoDFuJQh Qf5p+A== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 47kn5jqgsv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Jul 2025 07:54:07 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA04.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 5647s7Ng018292 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 4 Jul 2025 07:54:07 GMT Received: from hu-dikshita-hyd.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Fri, 4 Jul 2025 00:54:03 -0700 From: Dikshita Agarwal Date: Fri, 4 Jul 2025 13:23:13 +0530 Subject: [PATCH 13/25] media: iris: Initialize and deinitialize encoder instance structure Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20250704-iris-video-encoder-v1-13-b6ce24e273cf@quicinc.com> References: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> In-Reply-To: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> To: Vikash Garodia , Abhinav Kumar , Bryan O'Donoghue , Mauro Carvalho Chehab , Hans Verkuil , Stefan Schmidt , "Vedang Nagar" CC: , , , Dikshita Agarwal X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1751615599; l=14225; i=quic_dikshita@quicinc.com; s=20240917; h=from:subject:message-id; bh=TAtnf+/wWALLIC+DL+tLut/Gn9jkjaNVSOFRREnovH8=; b=8hJinV79Rv2jBOQPRa2qLYaltpnrUUJjjryElWsfCKqpLVJAT8J/LvD3EH0xAeE5FWVb5a/yW ix0Ey/PBk2MCHSwFDD/S5tRF8CkHf5h6dW6JIsNxrQNb8m4jL/MfYOX X-Developer-Key: i=quic_dikshita@quicinc.com; a=ed25519; pk=EEvKY6Ar1OI5SWf44FJ1Ebo1KuQEVbbf5UNPO+UHVhM= X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Authority-Analysis: v=2.4 cv=KtJN2XWN c=1 sm=1 tr=0 ts=6867889f cx=c_pps a=JYp8KDb2vCoCEuGobkYCKw==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=GEpy-HfZoHoA:10 a=IkcTkHD0fZMA:10 a=Wb1JkmetP80A:10 a=COk6AnOGAAAA:8 a=IxRwsDHPDr3CWsG-5R0A:9 a=QEXdDO2ut3YA:10 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-ORIG-GUID: ziDX17-s9qWaTwh8hvRFbXU87aIMsL3A X-Proofpoint-GUID: ziDX17-s9qWaTwh8hvRFbXU87aIMsL3A X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzA0MDA2MCBTYWx0ZWRfX0cIgje426PWn gzM3Sd/y+en5qKzQuciG4gtYW/qLrfeaBPpyriGItyP2TYgPFqSmZZGA+KEce5fqTX91GZQMTrB ehnCkOY4GZTqznGLLKW2jz5mjt3t2859lSJ0827UqWbr7hTMNWutj54cO36GPHqkf3fj2OODgi6 mOAZLxyc9vEEJWtetrsjNpBE21iCxDM7laMhVHoMKS74+k+7Khr8QGj1ubxnpi3c4EPgTpBu0MW kAKQzF50fY1wed4FdnZHSvPI+qGjSMdWDjc+NSxHEQPcSVl4Cx+sEYIU80XzAICOYnk2jrsOeuC ypVPIoo02UfPbbKOvLlPJVWroXx8ATp1FeXfveeP/n+7kNQsG1xQCvASWkzJom6nanj0+8FH/pO hSRD2I7shCqQnFfCynYwcpwOcsQoviNYk5OSwiAHSCaQN/k/7jVoR7mMN0XUprvCo3cPQUOt X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-04_03,2025-07-02_04,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 bulkscore=0 priorityscore=1501 malwarescore=0 suspectscore=0 mlxscore=0 spamscore=0 adultscore=0 lowpriorityscore=0 phishscore=0 clxscore=1015 mlxlogscore=999 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507040060 Introduce initialization and deinitialization for internal encoder instance structure with necessary hooks. Signed-off-by: Dikshita Agarwal Tested-by: Vikash Garodia # X1E80100 --- drivers/media/platform/qcom/iris/Makefile | 1 + drivers/media/platform/qcom/iris/iris_buffer.c | 59 ++++++++++++++++--= -- .../platform/qcom/iris/iris_hfi_gen1_command.c | 7 ++- .../platform/qcom/iris/iris_hfi_gen1_defines.h | 1 + drivers/media/platform/qcom/iris/iris_instance.h | 7 +++ drivers/media/platform/qcom/iris/iris_vdec.c | 2 - drivers/media/platform/qcom/iris/iris_venc.c | 65 ++++++++++++++++++= ++++ drivers/media/platform/qcom/iris/iris_venc.h | 14 +++++ drivers/media/platform/qcom/iris/iris_vidc.c | 27 ++++++++- drivers/media/platform/qcom/iris/iris_vpu_buffer.c | 5 +- 10 files changed, 170 insertions(+), 18 deletions(-) diff --git a/drivers/media/platform/qcom/iris/Makefile b/drivers/media/plat= form/qcom/iris/Makefile index e86d00ee6f15dda8bae2f25f726feb0d427b7684..ec32145e081b1fc3538dfa7d511= 3162a76a6068c 100644 --- a/drivers/media/platform/qcom/iris/Makefile +++ b/drivers/media/platform/qcom/iris/Makefile @@ -19,6 +19,7 @@ qcom-iris-objs +=3D \ iris_vidc.o \ iris_vb2.o \ iris_vdec.o \ + iris_venc.o \ iris_vpu2.o \ iris_vpu3x.o \ iris_vpu_buffer.o \ diff --git a/drivers/media/platform/qcom/iris/iris_buffer.c b/drivers/media= /platform/qcom/iris/iris_buffer.c index 3ab533310b2dfece11ea31b30d29ecb32e0c3f87..f9036057779830624eafe83e8c9= 06a05ec3b3210 100644 --- a/drivers/media/platform/qcom/iris/iris_buffer.c +++ b/drivers/media/platform/qcom/iris/iris_buffer.c @@ -63,7 +63,12 @@ static u32 iris_yuv_buffer_size_nv12(struct iris_inst *inst) { u32 y_plane, uv_plane, y_stride, uv_stride, y_scanlines, uv_scanlines; - struct v4l2_format *f =3D inst->fmt_dst; + struct v4l2_format *f; + + if (inst->domain =3D=3D DECODER) + f =3D inst->fmt_dst; + else + f =3D inst->fmt_src; =20 y_stride =3D ALIGN(f->fmt.pix_mp.width, Y_STRIDE_ALIGN); uv_stride =3D ALIGN(f->fmt.pix_mp.width, UV_STRIDE_ALIGN); @@ -194,7 +199,7 @@ static u32 iris_yuv_buffer_size_qc08c(struct iris_inst = *inst) return ALIGN(y_meta_plane + y_plane + uv_meta_plane + uv_plane, PIXELS_4K= ); } =20 -static u32 iris_bitstream_buffer_size(struct iris_inst *inst) +static u32 iris_dec_bitstream_buffer_size(struct iris_inst *inst) { struct platform_inst_caps *caps =3D inst->core->iris_platform_data->inst_= caps; u32 base_res_mbs =3D NUM_MBS_4K; @@ -219,18 +224,50 @@ static u32 iris_bitstream_buffer_size(struct iris_ins= t *inst) return ALIGN(frame_size, PIXELS_4K); } =20 +static u32 iris_enc_bitstream_buffer_size(struct iris_inst *inst) +{ + u32 aligned_width, aligned_height, bitstream_size, yuv_size; + struct v4l2_format *f; + + f =3D inst->fmt_dst; + + aligned_width =3D ALIGN(f->fmt.pix_mp.width, 32); + aligned_height =3D ALIGN(f->fmt.pix_mp.height, 32); + bitstream_size =3D aligned_width * aligned_height * 3; + yuv_size =3D (aligned_width * aligned_height * 3) >> 1; + if (aligned_width * aligned_height > (4096 * 2176)) + /* bitstream_size =3D 0.25 * yuv_size; */ + bitstream_size =3D (bitstream_size >> 3); + else if (aligned_width * aligned_height > (1280 * 720)) + /* bitstream_size =3D 0.5 * yuv_size; */ + bitstream_size =3D (bitstream_size >> 2); + + return ALIGN(bitstream_size, 4096); +} + int iris_get_buffer_size(struct iris_inst *inst, enum iris_buffer_type buffer_type) { - switch (buffer_type) { - case BUF_INPUT: - return iris_bitstream_buffer_size(inst); - case BUF_OUTPUT: - return iris_yuv_buffer_size_nv12(inst); - case BUF_DPB: - return iris_yuv_buffer_size_qc08c(inst); - default: - return 0; + if (inst->domain =3D=3D DECODER) { + switch (buffer_type) { + case BUF_INPUT: + return iris_dec_bitstream_buffer_size(inst); + case BUF_OUTPUT: + return iris_yuv_buffer_size_nv12(inst); + case BUF_DPB: + return iris_yuv_buffer_size_qc08c(inst); + default: + return 0; + } + } else { + switch (buffer_type) { + case BUF_INPUT: + return iris_yuv_buffer_size_nv12(inst); + case BUF_OUTPUT: + return iris_enc_bitstream_buffer_size(inst); + default: + return 0; + } } } =20 diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c b/dri= vers/media/platform/qcom/iris/iris_hfi_gen1_command.c index 5097680ee14ebba3a126213c0584161627ca47d7..eae3dc5c596d1eb6090126ac391= b8e0e2c9f09eb 100644 --- a/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c @@ -109,7 +109,12 @@ static int iris_hfi_gen1_session_open(struct iris_inst= *inst) packet.shdr.hdr.size =3D sizeof(struct hfi_session_open_pkt); packet.shdr.hdr.pkt_type =3D HFI_CMD_SYS_SESSION_INIT; packet.shdr.session_id =3D inst->session_id; - packet.session_domain =3D HFI_SESSION_TYPE_DEC; + + if (inst->domain =3D=3D DECODER) + packet.session_domain =3D HFI_SESSION_TYPE_DEC; + else + packet.session_domain =3D HFI_SESSION_TYPE_ENC; + packet.session_codec =3D codec; =20 reinit_completion(&inst->completion); diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen1_defines.h b/dri= vers/media/platform/qcom/iris/iris_hfi_gen1_defines.h index d4d119ca98b0cb313db351f3794bf278216bd539..5b7c641b727a16c3aa7196a6d49= 786133653279f 100644 --- a/drivers/media/platform/qcom/iris/iris_hfi_gen1_defines.h +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen1_defines.h @@ -10,6 +10,7 @@ =20 #define HFI_VIDEO_ARCH_OX 0x1 =20 +#define HFI_SESSION_TYPE_ENC 1 #define HFI_SESSION_TYPE_DEC 2 =20 #define HFI_VIDEO_CODEC_H264 0x00000002 diff --git a/drivers/media/platform/qcom/iris/iris_instance.h b/drivers/med= ia/platform/qcom/iris/iris_instance.h index 0e1f5799b72d993b25820608969e0011eabdb6bc..ff90f010f1d36690cbadeff0787= b1fb7458d7f75 100644 --- a/drivers/media/platform/qcom/iris/iris_instance.h +++ b/drivers/media/platform/qcom/iris/iris_instance.h @@ -12,6 +12,9 @@ #include "iris_core.h" #include "iris_utils.h" =20 +#define DEFAULT_WIDTH 320 +#define DEFAULT_HEIGHT 240 + /** * struct iris_inst - holds per video instance parameters * @@ -24,7 +27,9 @@ * @fmt_src: structure of v4l2_format for source * @fmt_dst: structure of v4l2_format for destination * @ctrl_handler: reference of v4l2 ctrl handler + * @domain: domain type: encoder or decoder * @crop: structure of crop info + * @compose: structure of compose info * @completion: structure of signal completions * @flush_completion: structure of signal completions for flush cmd * @flush_responses_pending: counter to track number of pending flush resp= onses @@ -57,7 +62,9 @@ struct iris_inst { struct v4l2_format *fmt_src; struct v4l2_format *fmt_dst; struct v4l2_ctrl_handler ctrl_handler; + enum domain_type domain; struct iris_hfi_rect_desc crop; + struct iris_hfi_rect_desc compose; struct completion completion; struct completion flush_completion; u32 flush_responses_pending; diff --git a/drivers/media/platform/qcom/iris/iris_vdec.c b/drivers/media/p= latform/qcom/iris/iris_vdec.c index 05340e201e6538b9599387cdd57814005b904e76..13c7d2e243f43161df62170e4b8= b56fc83b58193 100644 --- a/drivers/media/platform/qcom/iris/iris_vdec.c +++ b/drivers/media/platform/qcom/iris/iris_vdec.c @@ -13,8 +13,6 @@ #include "iris_vdec.h" #include "iris_vpu_buffer.h" =20 -#define DEFAULT_WIDTH 320 -#define DEFAULT_HEIGHT 240 #define DEFAULT_CODEC_ALIGNMENT 16 =20 int iris_vdec_inst_init(struct iris_inst *inst) diff --git a/drivers/media/platform/qcom/iris/iris_venc.c b/drivers/media/p= latform/qcom/iris/iris_venc.c new file mode 100644 index 0000000000000000000000000000000000000000..e418d347ac111c1bc48304adafa= 259d697e49fed --- /dev/null +++ b/drivers/media/platform/qcom/iris/iris_venc.c @@ -0,0 +1,65 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2022-2025 Qualcomm Innovation Center, Inc. All rights res= erved. + */ + +#include "iris_buffer.h" +#include "iris_instance.h" +#include "iris_venc.h" +#include "iris_vpu_buffer.h" + +int iris_venc_inst_init(struct iris_inst *inst) +{ + struct v4l2_format *f; + + inst->fmt_src =3D kzalloc(sizeof(*inst->fmt_src), GFP_KERNEL); + inst->fmt_dst =3D kzalloc(sizeof(*inst->fmt_dst), GFP_KERNEL); + if (!inst->fmt_src || !inst->fmt_dst) + return -ENOMEM; + + f =3D inst->fmt_dst; + f->type =3D V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; + f->fmt.pix_mp.width =3D DEFAULT_WIDTH; + f->fmt.pix_mp.height =3D DEFAULT_HEIGHT; + f->fmt.pix_mp.pixelformat =3D V4L2_PIX_FMT_H264; + inst->codec =3D f->fmt.pix_mp.pixelformat; + f->fmt.pix_mp.num_planes =3D 1; + f->fmt.pix_mp.plane_fmt[0].bytesperline =3D 0; + f->fmt.pix_mp.plane_fmt[0].sizeimage =3D iris_get_buffer_size(inst, BUF_O= UTPUT); + f->fmt.pix_mp.field =3D V4L2_FIELD_NONE; + f->fmt.pix_mp.colorspace =3D V4L2_COLORSPACE_DEFAULT; + f->fmt.pix_mp.xfer_func =3D V4L2_XFER_FUNC_DEFAULT; + f->fmt.pix_mp.ycbcr_enc =3D V4L2_YCBCR_ENC_DEFAULT; + f->fmt.pix_mp.quantization =3D V4L2_QUANTIZATION_DEFAULT; + inst->buffers[BUF_OUTPUT].min_count =3D iris_vpu_buf_count(inst, BUF_OUTP= UT); + inst->buffers[BUF_OUTPUT].size =3D f->fmt.pix_mp.plane_fmt[0].sizeimage; + + f =3D inst->fmt_src; + f->type =3D V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; + f->fmt.pix_mp.pixelformat =3D V4L2_PIX_FMT_NV12; + f->fmt.pix_mp.width =3D ALIGN(DEFAULT_WIDTH, 128); + f->fmt.pix_mp.height =3D ALIGN(DEFAULT_HEIGHT, 32); + f->fmt.pix_mp.num_planes =3D 1; + f->fmt.pix_mp.plane_fmt[0].bytesperline =3D ALIGN(DEFAULT_WIDTH, 128); + f->fmt.pix_mp.plane_fmt[0].sizeimage =3D iris_get_buffer_size(inst, BUF_I= NPUT); + f->fmt.pix_mp.field =3D V4L2_FIELD_NONE; + f->fmt.pix_mp.colorspace =3D V4L2_COLORSPACE_DEFAULT; + f->fmt.pix_mp.xfer_func =3D V4L2_XFER_FUNC_DEFAULT; + f->fmt.pix_mp.ycbcr_enc =3D V4L2_YCBCR_ENC_DEFAULT; + f->fmt.pix_mp.quantization =3D V4L2_QUANTIZATION_DEFAULT; + inst->buffers[BUF_INPUT].min_count =3D iris_vpu_buf_count(inst, BUF_INPUT= ); + inst->buffers[BUF_INPUT].size =3D f->fmt.pix_mp.plane_fmt[0].sizeimage; + + inst->crop.left =3D 0; + inst->crop.top =3D 0; + inst->crop.width =3D f->fmt.pix_mp.width; + inst->crop.height =3D f->fmt.pix_mp.height; + + return 0; +} + +void iris_venc_inst_deinit(struct iris_inst *inst) +{ + kfree(inst->fmt_dst); + kfree(inst->fmt_src); +} diff --git a/drivers/media/platform/qcom/iris/iris_venc.h b/drivers/media/p= latform/qcom/iris/iris_venc.h new file mode 100644 index 0000000000000000000000000000000000000000..8a4cbddd0114b6d0e4ea895362b= 01c302250c78b --- /dev/null +++ b/drivers/media/platform/qcom/iris/iris_venc.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2022-2025 Qualcomm Innovation Center, Inc. All rights res= erved. + */ + +#ifndef _IRIS_VENC_H_ +#define _IRIS_VENC_H_ + +struct iris_inst; + +int iris_venc_inst_init(struct iris_inst *inst); +void iris_venc_inst_deinit(struct iris_inst *inst); + +#endif diff --git a/drivers/media/platform/qcom/iris/iris_vidc.c b/drivers/media/p= latform/qcom/iris/iris_vidc.c index 96313856a026efaff40da97eaaa63e847172cd57..11f27fc867dc610c18022b0942e= 65aa175a8567e 100644 --- a/drivers/media/platform/qcom/iris/iris_vidc.c +++ b/drivers/media/platform/qcom/iris/iris_vidc.c @@ -12,6 +12,7 @@ #include "iris_vidc.h" #include "iris_instance.h" #include "iris_vdec.h" +#include "iris_venc.h" #include "iris_vb2.h" #include "iris_vpu_buffer.h" #include "iris_platform_common.h" @@ -23,7 +24,10 @@ =20 static void iris_v4l2_fh_init(struct iris_inst *inst) { - v4l2_fh_init(&inst->fh, inst->core->vdev_dec); + if (inst->domain =3D=3D ENCODER) + v4l2_fh_init(&inst->fh, inst->core->vdev_enc); + else if (inst->domain =3D=3D DECODER) + v4l2_fh_init(&inst->fh, inst->core->vdev_dec); inst->fh.ctrl_handler =3D &inst->ctrl_handler; v4l2_fh_add(&inst->fh); } @@ -126,9 +130,19 @@ iris_m2m_queue_init(void *priv, struct vb2_queue *src_= vq, struct vb2_queue *dst_ int iris_open(struct file *filp) { struct iris_core *core =3D video_drvdata(filp); + struct video_device *vdev; struct iris_inst *inst; + u32 session_type; int ret; =20 + vdev =3D video_devdata(filp); + if (strcmp(vdev->name, "qcom-iris-decoder") =3D=3D 0) + session_type =3D DECODER; + else if (strcmp(vdev->name, "qcom-iris-encoder") =3D=3D 0) + session_type =3D ENCODER; + else + return -EINVAL; + ret =3D pm_runtime_resume_and_get(core->dev); if (ret < 0) return ret; @@ -147,6 +161,7 @@ int iris_open(struct file *filp) return -ENOMEM; =20 inst->core =3D core; + inst->domain =3D session_type; inst->session_id =3D hash32_ptr(inst); inst->state =3D IRIS_INST_DEINIT; =20 @@ -178,7 +193,10 @@ int iris_open(struct file *filp) goto fail_m2m_release; } =20 - ret =3D iris_vdec_inst_init(inst); + if (inst->domain =3D=3D DECODER) + ret =3D iris_vdec_inst_init(inst); + else if (inst->domain =3D=3D ENCODER) + ret =3D iris_venc_inst_init(inst); if (ret) goto fail_m2m_ctx_release; =20 @@ -265,7 +283,10 @@ int iris_close(struct file *filp) v4l2_m2m_ctx_release(inst->m2m_ctx); v4l2_m2m_release(inst->m2m_dev); mutex_lock(&inst->lock); - iris_vdec_inst_deinit(inst); + if (inst->domain =3D=3D DECODER) + iris_vdec_inst_deinit(inst); + else if (inst->domain =3D=3D ENCODER) + iris_venc_inst_deinit(inst); iris_session_close(inst); iris_inst_change_state(inst, IRIS_INST_DEINIT); iris_v4l2_fh_deinit(inst); diff --git a/drivers/media/platform/qcom/iris/iris_vpu_buffer.c b/drivers/m= edia/platform/qcom/iris/iris_vpu_buffer.c index f92fd39fe310b9661f892dcf1ff036ebbc102270..06d5afc3c641f0dfca3967e5527= 3c4fa2614fdff 100644 --- a/drivers/media/platform/qcom/iris/iris_vpu_buffer.c +++ b/drivers/media/platform/qcom/iris/iris_vpu_buffer.c @@ -628,7 +628,10 @@ int iris_vpu_buf_count(struct iris_inst *inst, enum ir= is_buffer_type buffer_type case BUF_INPUT: return MIN_BUFFERS; case BUF_OUTPUT: - return output_min_count(inst); + if (inst->domain =3D=3D ENCODER) + return MIN_BUFFERS; + else + return output_min_count(inst); case BUF_BIN: case BUF_COMV: case BUF_NON_COMV: --=20 2.34.1 From nobody Tue Oct 7 22:51:46 2025 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 EFE7929E0F7; Fri, 4 Jul 2025 07:54:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615659; cv=none; b=p8vb+V6PMir3wrYAF9pwR8z5y50PCap73PxI/QRonJ1owdQPYZeKgd4cpw2HX3jSOb2e+7dNHMoVJoyw+6vg/U5qkhLOVUEgSuEzHafNM9Gjy4QHqu/eIy95lYOFFL6ZWEC5v0cvpH0gN+U6aWhBYelhGxX9VD6XG1R/aJsNi9E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615659; c=relaxed/simple; bh=F6+6wmW4gNsELkr2qUtIST5vjjLAl25J2+Zz2prT4So=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=tUwTmherA0RPb7fwY/WxkwgMuwfCQMtBNIDTqK9Kuk8Ij6WvxraWdWUZJzT9/rAg11NYlGVLul6RhTsrIm5A0sALtoWemRuw7jmRnEsM/YJItxntP+06t062jpGpyUlcifXkI35Ga/AQPKB0ZMw/CneV4hmNlcKY+V0ZdT61Moo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=IjCJwxG8; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="IjCJwxG8" Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 564752kF032128; Fri, 4 Jul 2025 07:54:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= iIlpnQ4FjOeY4aYwJ/ht8nPKjbM8ltv4m/sTu+bqM8Q=; b=IjCJwxG8iwf5rk1f /gfpb1AJb+lYVjpemAaaveBzFJmBprV1MW5Pv4M1i3cJv+JlFH0kpq+3oHIt1VUG 7b+Lhu4I4hIDLSzca/d3qan8atndQeS8zanLZ8QSgvRQf7wFLH5H356iE2GL0LNG I2FP90SlUvz6FZdpWrTTb/3ODsacdkRXKywkYW8Tx816lLf2CXGSVX63HLhz8V4D 6NjcpnkblFb+E+sSCqxBWaF7fWSTKSxnjf4kVCZPEvJvUYQXIyOqv48QpP0z8qV3 tAqD9JX+BiRQ5c9cVy3FVlIfcsS2jIrtnAfoU9h/aPR6ZSd3f0RuqSZEus9QlWmA DEh+3Q== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 47j63kka22-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Jul 2025 07:54:11 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA01.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 5647sA0F001614 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 4 Jul 2025 07:54:10 GMT Received: from hu-dikshita-hyd.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Fri, 4 Jul 2025 00:54:07 -0700 From: Dikshita Agarwal Date: Fri, 4 Jul 2025 13:23:14 +0530 Subject: [PATCH 14/25] media: iris: Add support for ENUM_FMT, S/G/TRY_FMT encoder Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20250704-iris-video-encoder-v1-14-b6ce24e273cf@quicinc.com> References: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> In-Reply-To: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> To: Vikash Garodia , Abhinav Kumar , Bryan O'Donoghue , Mauro Carvalho Chehab , Hans Verkuil , Stefan Schmidt , "Vedang Nagar" CC: , , , Dikshita Agarwal X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1751615599; l=15318; i=quic_dikshita@quicinc.com; s=20240917; h=from:subject:message-id; bh=F6+6wmW4gNsELkr2qUtIST5vjjLAl25J2+Zz2prT4So=; b=3H4GITqrhoHDTXyGkcaLZsaRPyC4e7vRGPUfVsX5n5Dxu7bO85WuNz3dem79/Ph9YhQHXGXiO vUQ+x0Ie7KvAgYwnx8L6UUOxnrhEf1EXaeyTuONcWINiXON0O7/lZGT X-Developer-Key: i=quic_dikshita@quicinc.com; a=ed25519; pk=EEvKY6Ar1OI5SWf44FJ1Ebo1KuQEVbbf5UNPO+UHVhM= X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Authority-Analysis: v=2.4 cv=ZKfXmW7b c=1 sm=1 tr=0 ts=686788a3 cx=c_pps a=JYp8KDb2vCoCEuGobkYCKw==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=GEpy-HfZoHoA:10 a=IkcTkHD0fZMA:10 a=Wb1JkmetP80A:10 a=COk6AnOGAAAA:8 a=MTZWs62D9r5BD9hYChMA:9 a=QEXdDO2ut3YA:10 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzA0MDA2MCBTYWx0ZWRfX3ghGCzQnK6J/ TwQbxZPxUELoNhMXAkxHGN4innpTqy31h6RxJXWvk2CeS2l61ZD8UmcGTCJm1qdAGt953WnMDEZ lNVx5+IWgzIohb+JfjqrsKImAh5HhbRk7l388JmqY6VsGISNk9IRYfhTZmFElmhGjSjOcGjhhyD 0uS/f6eZSKrOYTlQb+y5X4kLhElI+WaC/hq14m+ve7MMPD4HnWYqJdmNLa4YCo64KW8WLandTMX cdfByZSABiSOallc07tp4MhtefPbm/+DMTNS6VXqOKQmHqfG6JvLMumaV1yo/wdcLiwrvqr3+yp XAJgjX0jubRlfHE0I5WGVYup1l8/bofMizwvhxYeGrjSS5ES2+YKSHhVMl/yXTAC7MyLadpyJkx mUxa+FKGo+iZzwbB/8yBQ2tHDg5Q8yti1tfLjlXIlrgKglhwSvkGKBNJ6is/UOfX7lEUzl6A X-Proofpoint-ORIG-GUID: 5D9BB87f7p7926qlO-UdzKH23AmWbubN X-Proofpoint-GUID: 5D9BB87f7p7926qlO-UdzKH23AmWbubN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-04_03,2025-07-02_04,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxscore=0 mlxlogscore=999 spamscore=0 suspectscore=0 bulkscore=0 priorityscore=1501 lowpriorityscore=0 phishscore=0 impostorscore=0 malwarescore=0 clxscore=1015 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507040060 Add V4L2 format handling support for the encoder by adding implementation of ENUM/S/G/TRY_FMT with necessary hooks. This ensures that the encoder supports format negotiation consistent with V4L2 expectation, enabling userspace applications to configure resolution, pixel format and buffer layout properly. Signed-off-by: Dikshita Agarwal Tested-by: Vikash Garodia # X1E80100 --- drivers/media/platform/qcom/iris/iris_core.h | 6 +- drivers/media/platform/qcom/iris/iris_instance.h | 11 ++ drivers/media/platform/qcom/iris/iris_probe.c | 3 +- drivers/media/platform/qcom/iris/iris_vdec.h | 11 -- drivers/media/platform/qcom/iris/iris_venc.c | 207 +++++++++++++++++++= ++++ drivers/media/platform/qcom/iris/iris_venc.h | 3 + drivers/media/platform/qcom/iris/iris_vidc.c | 41 ++++- 7 files changed, 261 insertions(+), 21 deletions(-) diff --git a/drivers/media/platform/qcom/iris/iris_core.h b/drivers/media/p= latform/qcom/iris/iris_core.h index 09e83be4e00efb456b7098a499b6cce850134a06..827aee8dcec3ee17af5a90f5594= b9315f663c0b3 100644 --- a/drivers/media/platform/qcom/iris/iris_core.h +++ b/drivers/media/platform/qcom/iris/iris_core.h @@ -40,7 +40,8 @@ enum domain_type { * @vdev_dec: iris video device structure for decoder * @vdev_enc: iris video device structure for encoder * @iris_v4l2_file_ops: iris v4l2 file ops - * @iris_v4l2_ioctl_ops: iris v4l2 ioctl ops + * @iris_v4l2_ioctl_ops_dec: iris v4l2 ioctl ops for decoder + * @iris_v4l2_ioctl_ops_enc: iris v4l2 ioctl ops for encoder * @iris_vb2_ops: iris vb2 ops * @icc_tbl: table of iris interconnects * @icc_count: count of iris interconnects @@ -81,7 +82,8 @@ struct iris_core { struct video_device *vdev_dec; struct video_device *vdev_enc; const struct v4l2_file_operations *iris_v4l2_file_ops; - const struct v4l2_ioctl_ops *iris_v4l2_ioctl_ops; + const struct v4l2_ioctl_ops *iris_v4l2_ioctl_ops_dec; + const struct v4l2_ioctl_ops *iris_v4l2_ioctl_ops_enc; const struct vb2_ops *iris_vb2_ops; struct icc_bulk_data *icc_tbl; u32 icc_count; diff --git a/drivers/media/platform/qcom/iris/iris_instance.h b/drivers/med= ia/platform/qcom/iris/iris_instance.h index ff90f010f1d36690cbadeff0787b1fb7458d7f75..55cf9702111829ef24189986ba5= 245c7684bfe11 100644 --- a/drivers/media/platform/qcom/iris/iris_instance.h +++ b/drivers/media/platform/qcom/iris/iris_instance.h @@ -15,6 +15,17 @@ #define DEFAULT_WIDTH 320 #define DEFAULT_HEIGHT 240 =20 +enum iris_fmt_type { + IRIS_FMT_H264, + IRIS_FMT_HEVC, + IRIS_FMT_VP9, +}; + +struct iris_fmt { + u32 pixfmt; + u32 type; +}; + /** * struct iris_inst - holds per video instance parameters * diff --git a/drivers/media/platform/qcom/iris/iris_probe.c b/drivers/media/= platform/qcom/iris/iris_probe.c index c3be9deb0a57cc2cf25d69784d54be5e4a5fe06c..0f2596427a773e5c9105b97cb23= 4c8f0a3483226 100644 --- a/drivers/media/platform/qcom/iris/iris_probe.c +++ b/drivers/media/platform/qcom/iris/iris_probe.c @@ -157,19 +157,20 @@ static int iris_register_video_device(struct iris_cor= e *core, enum domain_type t =20 vdev->release =3D video_device_release; vdev->fops =3D core->iris_v4l2_file_ops; - vdev->ioctl_ops =3D core->iris_v4l2_ioctl_ops; vdev->vfl_dir =3D VFL_DIR_M2M; vdev->v4l2_dev =3D &core->v4l2_dev; vdev->device_caps =3D V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_STREAMING; =20 if (type =3D=3D DECODER) { strscpy(vdev->name, "qcom-iris-decoder", sizeof(vdev->name)); + vdev->ioctl_ops =3D core->iris_v4l2_ioctl_ops_dec; ret =3D video_register_device(vdev, VFL_TYPE_VIDEO, -1); if (ret) goto err_vdev_release; core->vdev_dec =3D vdev; } else if (type =3D=3D ENCODER) { strscpy(vdev->name, "qcom-iris-encoder", sizeof(vdev->name)); + vdev->ioctl_ops =3D core->iris_v4l2_ioctl_ops_enc; ret =3D video_register_device(vdev, VFL_TYPE_VIDEO, -1); if (ret) goto err_vdev_release; diff --git a/drivers/media/platform/qcom/iris/iris_vdec.h b/drivers/media/p= latform/qcom/iris/iris_vdec.h index cd7aab66dc7c82dc50acef9e654a3d6c1ddb088f..b24932dc511a65017b1cadbcb98= 4544475bd0723 100644 --- a/drivers/media/platform/qcom/iris/iris_vdec.h +++ b/drivers/media/platform/qcom/iris/iris_vdec.h @@ -8,17 +8,6 @@ =20 struct iris_inst; =20 -enum iris_fmt_type { - IRIS_FMT_H264, - IRIS_FMT_HEVC, - IRIS_FMT_VP9, -}; - -struct iris_fmt { - u32 pixfmt; - u32 type; -}; - int iris_vdec_inst_init(struct iris_inst *inst); void iris_vdec_inst_deinit(struct iris_inst *inst); int iris_vdec_enum_fmt(struct iris_inst *inst, struct v4l2_fmtdesc *f); diff --git a/drivers/media/platform/qcom/iris/iris_venc.c b/drivers/media/p= latform/qcom/iris/iris_venc.c index e418d347ac111c1bc48304adafa259d697e49fed..6bb59ce4fc565d3dcc6185233ef= 25d2e4d85cb3e 100644 --- a/drivers/media/platform/qcom/iris/iris_venc.c +++ b/drivers/media/platform/qcom/iris/iris_venc.c @@ -3,6 +3,8 @@ * Copyright (c) 2022-2025 Qualcomm Innovation Center, Inc. All rights res= erved. */ =20 +#include + #include "iris_buffer.h" #include "iris_instance.h" #include "iris_venc.h" @@ -63,3 +65,208 @@ void iris_venc_inst_deinit(struct iris_inst *inst) kfree(inst->fmt_dst); kfree(inst->fmt_src); } + +static const struct iris_fmt iris_venc_formats[] =3D { + [IRIS_FMT_H264] =3D { + .pixfmt =3D V4L2_PIX_FMT_H264, + .type =3D V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, + }, + [IRIS_FMT_HEVC] =3D { + .pixfmt =3D V4L2_PIX_FMT_HEVC, + .type =3D V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, + }, +}; + +static const struct iris_fmt * +find_format(struct iris_inst *inst, u32 pixfmt, u32 type) +{ + const struct iris_fmt *fmt =3D iris_venc_formats; + unsigned int size =3D ARRAY_SIZE(iris_venc_formats); + unsigned int i; + + for (i =3D 0; i < size; i++) { + if (fmt[i].pixfmt =3D=3D pixfmt) + break; + } + + if (i =3D=3D size || fmt[i].type !=3D type) + return NULL; + + return &fmt[i]; +} + +static const struct iris_fmt * +find_format_by_index(struct iris_inst *inst, u32 index, u32 type) +{ + const struct iris_fmt *fmt =3D iris_venc_formats; + unsigned int size =3D ARRAY_SIZE(iris_venc_formats); + + if (index >=3D size || fmt[index].type !=3D type) + return NULL; + + return &fmt[index]; +} + +int iris_venc_enum_fmt(struct iris_inst *inst, struct v4l2_fmtdesc *f) +{ + const struct iris_fmt *fmt; + + switch (f->type) { + case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: + if (f->index) + return -EINVAL; + f->pixelformat =3D V4L2_PIX_FMT_NV12; + break; + case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: + fmt =3D find_format_by_index(inst, f->index, f->type); + if (!fmt) + return -EINVAL; + + f->pixelformat =3D fmt->pixfmt; + f->flags =3D V4L2_FMT_FLAG_COMPRESSED | V4L2_FMT_FLAG_ENC_CAP_FRAME_INTE= RVAL; + break; + default: + return -EINVAL; + } + + return 0; +} + +int iris_venc_try_fmt(struct iris_inst *inst, struct v4l2_format *f) +{ + struct v4l2_pix_format_mplane *pixmp =3D &f->fmt.pix_mp; + const struct iris_fmt *fmt; + struct v4l2_format *f_inst; + + memset(pixmp->reserved, 0, sizeof(pixmp->reserved)); + fmt =3D find_format(inst, pixmp->pixelformat, f->type); + switch (f->type) { + case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: + if (f->fmt.pix_mp.pixelformat !=3D V4L2_PIX_FMT_NV12) { + f_inst =3D inst->fmt_src; + f->fmt.pix_mp.width =3D f_inst->fmt.pix_mp.width; + f->fmt.pix_mp.height =3D f_inst->fmt.pix_mp.height; + f->fmt.pix_mp.pixelformat =3D f_inst->fmt.pix_mp.pixelformat; + } + break; + case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: + if (!fmt) { + f_inst =3D inst->fmt_dst; + f->fmt.pix_mp.width =3D f_inst->fmt.pix_mp.width; + f->fmt.pix_mp.height =3D f_inst->fmt.pix_mp.height; + f->fmt.pix_mp.pixelformat =3D f_inst->fmt.pix_mp.pixelformat; + } + break; + default: + return -EINVAL; + } + + if (pixmp->field =3D=3D V4L2_FIELD_ANY) + pixmp->field =3D V4L2_FIELD_NONE; + + pixmp->num_planes =3D 1; + + return 0; +} + +static int iris_venc_s_fmt_output(struct iris_inst *inst, struct v4l2_form= at *f) +{ + struct v4l2_format *fmt; + + iris_venc_try_fmt(inst, f); + + if (!(find_format(inst, f->fmt.pix_mp.pixelformat, f->type))) + return -EINVAL; + + fmt =3D inst->fmt_dst; + fmt->type =3D V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; + fmt->fmt.pix_mp.num_planes =3D 1; + fmt->fmt.pix_mp.plane_fmt[0].bytesperline =3D 0; + fmt->fmt.pix_mp.plane_fmt[0].sizeimage =3D iris_get_buffer_size(inst, BUF= _OUTPUT); + + if (f->fmt.pix_mp.colorspace !=3D V4L2_COLORSPACE_DEFAULT && + f->fmt.pix_mp.colorspace !=3D V4L2_COLORSPACE_REC709) + f->fmt.pix_mp.colorspace =3D V4L2_COLORSPACE_DEFAULT; + fmt->fmt.pix_mp.colorspace =3D f->fmt.pix_mp.colorspace; + fmt->fmt.pix_mp.xfer_func =3D f->fmt.pix_mp.xfer_func; + fmt->fmt.pix_mp.ycbcr_enc =3D f->fmt.pix_mp.ycbcr_enc; + fmt->fmt.pix_mp.quantization =3D f->fmt.pix_mp.quantization; + + inst->buffers[BUF_OUTPUT].min_count =3D iris_vpu_buf_count(inst, BUF_OUTP= UT); + inst->buffers[BUF_OUTPUT].size =3D fmt->fmt.pix_mp.plane_fmt[0].sizeimage; + fmt->fmt.pix_mp.pixelformat =3D f->fmt.pix_mp.pixelformat; + inst->codec =3D f->fmt.pix_mp.pixelformat; + memcpy(f, fmt, sizeof(struct v4l2_format)); + + return 0; +} + +static int iris_venc_s_fmt_input(struct iris_inst *inst, struct v4l2_forma= t *f) +{ + struct v4l2_format *fmt, *output_fmt; + + iris_venc_try_fmt(inst, f); + + if (f->fmt.pix_mp.pixelformat !=3D V4L2_PIX_FMT_NV12) + return -EINVAL; + + fmt =3D inst->fmt_src; + fmt->type =3D V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; + fmt->fmt.pix_mp.width =3D ALIGN(f->fmt.pix_mp.width, 128); + fmt->fmt.pix_mp.height =3D ALIGN(f->fmt.pix_mp.height, 32); + fmt->fmt.pix_mp.num_planes =3D 1; + fmt->fmt.pix_mp.pixelformat =3D f->fmt.pix_mp.pixelformat; + fmt->fmt.pix_mp.plane_fmt[0].bytesperline =3D ALIGN(f->fmt.pix_mp.width, = 128); + fmt->fmt.pix_mp.plane_fmt[0].sizeimage =3D iris_get_buffer_size(inst, BUF= _INPUT); + + fmt->fmt.pix_mp.colorspace =3D f->fmt.pix_mp.colorspace; + fmt->fmt.pix_mp.xfer_func =3D f->fmt.pix_mp.xfer_func; + fmt->fmt.pix_mp.ycbcr_enc =3D f->fmt.pix_mp.ycbcr_enc; + fmt->fmt.pix_mp.quantization =3D f->fmt.pix_mp.quantization; + + output_fmt =3D inst->fmt_dst; + output_fmt->fmt.pix_mp.width =3D fmt->fmt.pix_mp.width; + output_fmt->fmt.pix_mp.height =3D fmt->fmt.pix_mp.height; + output_fmt->fmt.pix_mp.colorspace =3D fmt->fmt.pix_mp.colorspace; + output_fmt->fmt.pix_mp.xfer_func =3D fmt->fmt.pix_mp.xfer_func; + output_fmt->fmt.pix_mp.ycbcr_enc =3D fmt->fmt.pix_mp.ycbcr_enc; + output_fmt->fmt.pix_mp.quantization =3D fmt->fmt.pix_mp.quantization; + + inst->buffers[BUF_INPUT].min_count =3D iris_vpu_buf_count(inst, BUF_INPUT= ); + inst->buffers[BUF_INPUT].size =3D fmt->fmt.pix_mp.plane_fmt[0].sizeimage; + + if (f->fmt.pix_mp.width !=3D inst->crop.width || + f->fmt.pix_mp.height !=3D inst->crop.height) { + inst->crop.top =3D 0; + inst->crop.left =3D 0; + inst->crop.width =3D fmt->fmt.pix_mp.width; + inst->crop.height =3D fmt->fmt.pix_mp.height; + + iris_venc_s_fmt_output(inst, output_fmt); + } + + memcpy(f, fmt, sizeof(struct v4l2_format)); + + return 0; +} + +int iris_venc_s_fmt(struct iris_inst *inst, struct v4l2_format *f) +{ + struct vb2_queue *q; + + q =3D v4l2_m2m_get_vq(inst->m2m_ctx, f->type); + if (!q) + return -EINVAL; + + if (vb2_is_busy(q)) + return -EBUSY; + + switch (f->type) { + case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: + return iris_venc_s_fmt_input(inst, f); + case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: + return iris_venc_s_fmt_output(inst, f); + default: + return -EINVAL; + } +} diff --git a/drivers/media/platform/qcom/iris/iris_venc.h b/drivers/media/p= latform/qcom/iris/iris_venc.h index 8a4cbddd0114b6d0e4ea895362b01c302250c78b..eb26a3ecbd98b3f02dfdea0dfc4= 1bcd3a90904b6 100644 --- a/drivers/media/platform/qcom/iris/iris_venc.h +++ b/drivers/media/platform/qcom/iris/iris_venc.h @@ -10,5 +10,8 @@ struct iris_inst; =20 int iris_venc_inst_init(struct iris_inst *inst); void iris_venc_inst_deinit(struct iris_inst *inst); +int iris_venc_enum_fmt(struct iris_inst *inst, struct v4l2_fmtdesc *f); +int iris_venc_try_fmt(struct iris_inst *inst, struct v4l2_format *f); +int iris_venc_s_fmt(struct iris_inst *inst, struct v4l2_format *f); =20 #endif diff --git a/drivers/media/platform/qcom/iris/iris_vidc.c b/drivers/media/p= latform/qcom/iris/iris_vidc.c index 11f27fc867dc610c18022b0942e65aa175a8567e..06b2737c5892ebbcf43b4cff660= 62d85cf805c20 100644 --- a/drivers/media/platform/qcom/iris/iris_vidc.c +++ b/drivers/media/platform/qcom/iris/iris_vidc.c @@ -308,16 +308,26 @@ static int iris_enum_fmt(struct file *filp, void *fh,= struct v4l2_fmtdesc *f) { struct iris_inst *inst =3D iris_get_inst(filp, NULL); =20 - return iris_vdec_enum_fmt(inst, f); + if (inst->domain =3D=3D DECODER) + return iris_vdec_enum_fmt(inst, f); + else if (inst->domain =3D=3D ENCODER) + return iris_venc_enum_fmt(inst, f); + else + return -EINVAL; } =20 static int iris_try_fmt_vid_mplane(struct file *filp, void *fh, struct v4l= 2_format *f) { struct iris_inst *inst =3D iris_get_inst(filp, NULL); - int ret; + int ret =3D 0; =20 mutex_lock(&inst->lock); - ret =3D iris_vdec_try_fmt(inst, f); + + if (inst->domain =3D=3D DECODER) + ret =3D iris_vdec_try_fmt(inst, f); + else if (inst->domain =3D=3D ENCODER) + ret =3D iris_venc_try_fmt(inst, f); + mutex_unlock(&inst->lock); =20 return ret; @@ -326,10 +336,15 @@ static int iris_try_fmt_vid_mplane(struct file *filp,= void *fh, struct v4l2_form static int iris_s_fmt_vid_mplane(struct file *filp, void *fh, struct v4l2_= format *f) { struct iris_inst *inst =3D iris_get_inst(filp, NULL); - int ret; + int ret =3D 0; =20 mutex_lock(&inst->lock); - ret =3D iris_vdec_s_fmt(inst, f); + + if (inst->domain =3D=3D DECODER) + ret =3D iris_vdec_s_fmt(inst, f); + else if (inst->domain =3D=3D ENCODER) + ret =3D iris_venc_s_fmt(inst, f); + mutex_unlock(&inst->lock); =20 return ret; @@ -473,7 +488,7 @@ static const struct vb2_ops iris_vb2_ops =3D { .buf_queue =3D iris_vb2_buf_queue, }; =20 -static const struct v4l2_ioctl_ops iris_v4l2_ioctl_ops =3D { +static const struct v4l2_ioctl_ops iris_v4l2_ioctl_ops_dec =3D { .vidioc_enum_fmt_vid_cap =3D iris_enum_fmt, .vidioc_enum_fmt_vid_out =3D iris_enum_fmt, .vidioc_try_fmt_vid_cap_mplane =3D iris_try_fmt_vid_mplane, @@ -501,9 +516,21 @@ static const struct v4l2_ioctl_ops iris_v4l2_ioctl_ops= =3D { .vidioc_decoder_cmd =3D iris_dec_cmd, }; =20 +static const struct v4l2_ioctl_ops iris_v4l2_ioctl_ops_enc =3D { + .vidioc_enum_fmt_vid_cap =3D iris_enum_fmt, + .vidioc_enum_fmt_vid_out =3D iris_enum_fmt, + .vidioc_try_fmt_vid_cap_mplane =3D iris_try_fmt_vid_mplane, + .vidioc_try_fmt_vid_out_mplane =3D iris_try_fmt_vid_mplane, + .vidioc_s_fmt_vid_cap_mplane =3D iris_s_fmt_vid_mplane, + .vidioc_s_fmt_vid_out_mplane =3D iris_s_fmt_vid_mplane, + .vidioc_g_fmt_vid_cap_mplane =3D iris_g_fmt_vid_mplane, + .vidioc_g_fmt_vid_out_mplane =3D iris_g_fmt_vid_mplane, +}; + void iris_init_ops(struct iris_core *core) { core->iris_v4l2_file_ops =3D &iris_v4l2_file_ops; core->iris_vb2_ops =3D &iris_vb2_ops; - core->iris_v4l2_ioctl_ops =3D &iris_v4l2_ioctl_ops; + core->iris_v4l2_ioctl_ops_dec =3D &iris_v4l2_ioctl_ops_dec; + core->iris_v4l2_ioctl_ops_enc =3D &iris_v4l2_ioctl_ops_enc; } --=20 2.34.1 From nobody Tue Oct 7 22:51:46 2025 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 844A82C1590; Fri, 4 Jul 2025 07:54:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615664; cv=none; b=I5rYiRLnKqUaoO8nWJWRXDuV3x2viZnMIVcohy/roSwIw5cUlpptM7CfbvAbHEBG/kDlxHf+4F34r1nwKXHINoIFJRsqHZV2KYgVrv5ItQQ/ttG8lifUgsDbE+th5qHxOHezE53+Bkhpf+eq/INsWtoPCN9Y7g4BWL7Uvr4eouI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615664; c=relaxed/simple; bh=rBSFMZQnlFkvmsGXnjAJ+7RcBneq8uRcI3+uzvSGBvI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=CSQQU/1yaWZME7o/f02S/AVWFtLauBCh8JE3wjs1lkb06ZV8VmmT1P85aFP3g90nD73LzLLFD41Si8KUeMVPkinQ8pWgTIAzPCBlhtj+8c2uuEbbtnleUAKHFUBunu8dSzzIxU+KfeVWciYV9Toplff1+lrRltFFwpmyA3ddXQI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=LnG4mx2w; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="LnG4mx2w" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 563KD02A029559; Fri, 4 Jul 2025 07:54:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= H/HOPQfCpqiYF4bnOARS1c3kqC4SasfVC58+K1fcYkc=; b=LnG4mx2wSBafnE3O 6yOTFCxwOrI5XLmBmxJNtaFs9fl/GG8he8cEPonK1MZRcdpxivBC5LlsNyii6xv7 6NBpN2KwhEAazvHEv2ZS50mRUZnLtWrqqEhQ3VtDU38Pm341EmeaTBZobtBvpjo1 Sb5DrDsCxtds4ChsAC/nhbV9toM2QyrfcHYvQIHWCb4Re9tT4bEBsVBaTd6mmF3o MOeZlpvf/GUzdi3o537FImeQPZQB3nfo3bkY7ny7TQxYbQSX3tsho4IWhCs1Vs2C zkQ0vsWkuit4jaZ1UhAsIQfTP7DQc0aok4WnOhdtRHvlPFK5t5Rh8BupiQgGgbLR 3fourQ== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 47nh9s4brx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Jul 2025 07:54:14 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA01.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 5647sEPY001670 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 4 Jul 2025 07:54:14 GMT Received: from hu-dikshita-hyd.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Fri, 4 Jul 2025 00:54:10 -0700 From: Dikshita Agarwal Date: Fri, 4 Jul 2025 13:23:15 +0530 Subject: [PATCH 15/25] media: iris: Add support for ENUM_FRAMESIZES/FRAMEINTERVALS for encoder Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20250704-iris-video-encoder-v1-15-b6ce24e273cf@quicinc.com> References: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> In-Reply-To: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> To: Vikash Garodia , Abhinav Kumar , Bryan O'Donoghue , Mauro Carvalho Chehab , Hans Verkuil , Stefan Schmidt , "Vedang Nagar" CC: , , , Dikshita Agarwal X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1751615599; l=9939; i=quic_dikshita@quicinc.com; s=20240917; h=from:subject:message-id; bh=rBSFMZQnlFkvmsGXnjAJ+7RcBneq8uRcI3+uzvSGBvI=; b=RZmFK+8IOeWk9WSz8o7KoN+nnoIleRlVMENzrVmLq8xTVgc5OEoOyju1cQ215d2pdGKHU8nH7 q9V25euSqpSDuq14xi6ddT/JCH2xqhyEMI6KIxjJ5zAmBQuYzVkbTg0 X-Developer-Key: i=quic_dikshita@quicinc.com; a=ed25519; pk=EEvKY6Ar1OI5SWf44FJ1Ebo1KuQEVbbf5UNPO+UHVhM= X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Authority-Analysis: v=2.4 cv=frrcZE4f c=1 sm=1 tr=0 ts=686788a6 cx=c_pps a=JYp8KDb2vCoCEuGobkYCKw==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=GEpy-HfZoHoA:10 a=IkcTkHD0fZMA:10 a=Wb1JkmetP80A:10 a=COk6AnOGAAAA:8 a=1QD8j7rrkHTDSVgEayQA:9 a=QEXdDO2ut3YA:10 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzA0MDA2MCBTYWx0ZWRfXyPUocmpTTOgF jYgi/UouMOQ1w5Y1NUI8b8MkDuIRZmcVrZToWBPrwtwGhg6qx85aBO5Z633mbcO9+tbyjeylcnw UGyNzzeBsqJZG/0HxSaXHw+IEyenaIRxfrwSjngVo/GRJIwiA52uyPtY8xlwO7s7xdFS94VV9gi smrwfUfOG4UcopTZKDLOCRgLWIezwObg5AZEZrTOKjaXnh+cW5/Mg0724s7NB8GUt4JonKs/nX2 w+FDBlP3RPb90VNZYInZi0XLoICs/vkvQnxJi1CeRsm4OM+DrEc2V+IvzDf/27fdnuHwZF7B7WY lBmkAaKJPSDefAthH+iwVPDlqOQrQ2OVWWpWPQU7hyPeYdd/xOgxeyDJzrVnptOTnKbL9h98l/y 8Vdmllu3wXrXG52wONdDIBgTBDwgvuIXapf7GsUhdJ6xFGpPKYRTqvqV08ZAl6QjjSnS6ZYz X-Proofpoint-GUID: r3_WAGQJTEl_qoY0ljyPXR2E3Q4gBDcL X-Proofpoint-ORIG-GUID: r3_WAGQJTEl_qoY0ljyPXR2E3Q4gBDcL X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-04_03,2025-07-02_04,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxlogscore=999 bulkscore=0 spamscore=0 adultscore=0 impostorscore=0 clxscore=1015 lowpriorityscore=0 suspectscore=0 mlxscore=0 priorityscore=1501 malwarescore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507040060 Add support for frame size and frame interval enumeration by implementing ENUM_FRAMESIZES/FRAMEINTERVALS V4L2 ioctls for encoder video device with necessary hooks. This allows userspace application to query encoder capabilities and adapt encoding configurations accordingly. Signed-off-by: Dikshita Agarwal Tested-by: Vikash Garodia # X1E80100 --- .../platform/qcom/iris/iris_platform_common.h | 5 +- .../media/platform/qcom/iris/iris_platform_gen2.c | 3 ++ .../platform/qcom/iris/iris_platform_sm8250.c | 1 + drivers/media/platform/qcom/iris/iris_vdec.c | 13 +++++ drivers/media/platform/qcom/iris/iris_vdec.h | 1 + drivers/media/platform/qcom/iris/iris_venc.c | 13 +++++ drivers/media/platform/qcom/iris/iris_venc.h | 1 + drivers/media/platform/qcom/iris/iris_vidc.c | 58 ++++++++++++++++++= ++-- 8 files changed, 91 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/qcom/iris/iris_platform_common.h b/driv= ers/media/platform/qcom/iris/iris_platform_common.h index adafdce8a856f9c661aabc5ca28f0faceaa93551..792f46e2e34fd564a1ed61523f7= 2826fc8f74582 100644 --- a/drivers/media/platform/qcom/iris/iris_platform_common.h +++ b/drivers/media/platform/qcom/iris/iris_platform_common.h @@ -21,7 +21,8 @@ struct iris_inst; #define DEFAULT_MAX_HOST_BUF_COUNT 64 #define DEFAULT_MAX_HOST_BURST_BUF_COUNT 256 #define DEFAULT_FPS 30 -#define NUM_MBS_8K ((8192 * 4352) / 256) +#define MAXIMUM_FPS 480 +#define NUM_MBS_8K ((8192 * 4352) / 256) =20 enum stage_type { STAGE_1 =3D 1, @@ -179,6 +180,8 @@ struct iris_platform_data { u32 max_session_count; /* max number of macroblocks per frame supported */ u32 max_core_mbpf; + /* max number of macroblocks per second supported */ + u32 max_core_mbps; const u32 *input_config_params_default; unsigned int input_config_params_default_size; const u32 *input_config_params_hevc; diff --git a/drivers/media/platform/qcom/iris/iris_platform_gen2.c b/driver= s/media/platform/qcom/iris/iris_platform_gen2.c index d3026b2bcb708c7ec31f134f628df7e57b54af4f..1e2fadfe17672029b46e07ce00a= 8e31e0711fd58 100644 --- a/drivers/media/platform/qcom/iris/iris_platform_gen2.c +++ b/drivers/media/platform/qcom/iris/iris_platform_gen2.c @@ -354,6 +354,7 @@ struct iris_platform_data sm8550_data =3D { .num_vpp_pipe =3D 4, .max_session_count =3D 16, .max_core_mbpf =3D NUM_MBS_8K * 2, + .max_core_mbps =3D ((7680 * 4320) / 256) * 60, .input_config_params_default =3D sm8550_vdec_input_config_params_default, .input_config_params_default_size =3D @@ -429,6 +430,7 @@ struct iris_platform_data sm8650_data =3D { .num_vpp_pipe =3D 4, .max_session_count =3D 16, .max_core_mbpf =3D NUM_MBS_8K * 2, + .max_core_mbps =3D ((7680 * 4320) / 256) * 60, .input_config_params_default =3D sm8550_vdec_input_config_params_default, .input_config_params_default_size =3D @@ -500,6 +502,7 @@ struct iris_platform_data qcs8300_data =3D { .num_vpp_pipe =3D 2, .max_session_count =3D 16, .max_core_mbpf =3D ((4096 * 2176) / 256) * 4, + .max_core_mbps =3D ((7680 * 4320) / 256) * 60, //TODO confirm!! .input_config_params_default =3D sm8550_vdec_input_config_params_default, .input_config_params_default_size =3D diff --git a/drivers/media/platform/qcom/iris/iris_platform_sm8250.c b/driv= ers/media/platform/qcom/iris/iris_platform_sm8250.c index 8d0816a67ae0b6886204ce93fa5ccafaac10392a..2a3cbe1f2d4b27d3cce9e9cdad1= 525801d71a041 100644 --- a/drivers/media/platform/qcom/iris/iris_platform_sm8250.c +++ b/drivers/media/platform/qcom/iris/iris_platform_sm8250.c @@ -128,6 +128,7 @@ struct iris_platform_data sm8250_data =3D { .num_vpp_pipe =3D 4, .max_session_count =3D 16, .max_core_mbpf =3D NUM_MBS_8K, + .max_core_mbps =3D ((7680 * 4320) / 256) * 60, .input_config_params_default =3D sm8250_vdec_input_config_param_default, .input_config_params_default_size =3D diff --git a/drivers/media/platform/qcom/iris/iris_vdec.c b/drivers/media/p= latform/qcom/iris/iris_vdec.c index 13c7d2e243f43161df62170e4b8b56fc83b58193..0fb863426cdf479c50cad8a627c= 2845a6dfe0b32 100644 --- a/drivers/media/platform/qcom/iris/iris_vdec.c +++ b/drivers/media/platform/qcom/iris/iris_vdec.c @@ -263,6 +263,19 @@ int iris_vdec_s_fmt(struct iris_inst *inst, struct v4l= 2_format *f) return 0; } =20 +int iris_vdec_validate_format(struct iris_inst *inst, u32 pixelformat) +{ + const struct iris_fmt *fmt =3D NULL; + + if (pixelformat !=3D V4L2_PIX_FMT_NV12) { + fmt =3D find_format(inst, pixelformat, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE= ); + if (!fmt) + return -EINVAL; + } + + return 0; +} + int iris_vdec_subscribe_event(struct iris_inst *inst, const struct v4l2_ev= ent_subscription *sub) { int ret =3D 0; diff --git a/drivers/media/platform/qcom/iris/iris_vdec.h b/drivers/media/p= latform/qcom/iris/iris_vdec.h index b24932dc511a65017b1cadbcb984544475bd0723..097e02bfa72b5ac4e46e66c6184= 2df1d9dd4565b 100644 --- a/drivers/media/platform/qcom/iris/iris_vdec.h +++ b/drivers/media/platform/qcom/iris/iris_vdec.h @@ -13,6 +13,7 @@ void iris_vdec_inst_deinit(struct iris_inst *inst); int iris_vdec_enum_fmt(struct iris_inst *inst, struct v4l2_fmtdesc *f); int iris_vdec_try_fmt(struct iris_inst *inst, struct v4l2_format *f); int iris_vdec_s_fmt(struct iris_inst *inst, struct v4l2_format *f); +int iris_vdec_validate_format(struct iris_inst *inst, u32 pixelformat); int iris_vdec_subscribe_event(struct iris_inst *inst, const struct v4l2_ev= ent_subscription *sub); void iris_vdec_src_change(struct iris_inst *inst); int iris_vdec_streamon_input(struct iris_inst *inst); diff --git a/drivers/media/platform/qcom/iris/iris_venc.c b/drivers/media/p= latform/qcom/iris/iris_venc.c index 6bb59ce4fc565d3dcc6185233ef25d2e4d85cb3e..301206253090962abbb4e4eac8e= e88e7b359c98d 100644 --- a/drivers/media/platform/qcom/iris/iris_venc.c +++ b/drivers/media/platform/qcom/iris/iris_venc.c @@ -270,3 +270,16 @@ int iris_venc_s_fmt(struct iris_inst *inst, struct v4l= 2_format *f) return -EINVAL; } } + +int iris_venc_validate_format(struct iris_inst *inst, u32 pixelformat) +{ + const struct iris_fmt *fmt =3D NULL; + + if (pixelformat !=3D V4L2_PIX_FMT_NV12) { + fmt =3D find_format(inst, pixelformat, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLAN= E); + if (!fmt) + return -EINVAL; + } + + return 0; +} diff --git a/drivers/media/platform/qcom/iris/iris_venc.h b/drivers/media/p= latform/qcom/iris/iris_venc.h index eb26a3ecbd98b3f02dfdea0dfc41bcd3a90904b6..04fd41275547c40c359c6ea04df= e4ee31d2d0df6 100644 --- a/drivers/media/platform/qcom/iris/iris_venc.h +++ b/drivers/media/platform/qcom/iris/iris_venc.h @@ -13,5 +13,6 @@ void iris_venc_inst_deinit(struct iris_inst *inst); int iris_venc_enum_fmt(struct iris_inst *inst, struct v4l2_fmtdesc *f); int iris_venc_try_fmt(struct iris_inst *inst, struct v4l2_format *f); int iris_venc_s_fmt(struct iris_inst *inst, struct v4l2_format *f); +int iris_venc_validate_format(struct iris_inst *inst, u32 pixelformat); =20 #endif diff --git a/drivers/media/platform/qcom/iris/iris_vidc.c b/drivers/media/p= latform/qcom/iris/iris_vidc.c index 06b2737c5892ebbcf43b4cff66062d85cf805c20..cb1280c0c6c82187243f0bda4d9= 8e42370ee787c 100644 --- a/drivers/media/platform/qcom/iris/iris_vidc.c +++ b/drivers/media/platform/qcom/iris/iris_vidc.c @@ -373,13 +373,18 @@ static int iris_enum_framesizes(struct file *filp, vo= id *fh, { struct iris_inst *inst =3D iris_get_inst(filp, NULL); struct platform_inst_caps *caps; + int ret =3D 0; =20 if (fsize->index) return -EINVAL; =20 - if (fsize->pixel_format !=3D V4L2_PIX_FMT_H264 && - fsize->pixel_format !=3D V4L2_PIX_FMT_NV12) - return -EINVAL; + if (inst->domain =3D=3D DECODER) + ret =3D iris_vdec_validate_format(inst, fsize->pixel_format); + else + ret =3D iris_venc_validate_format(inst, fsize->pixel_format); + + if (ret) + return ret; =20 caps =3D inst->core->iris_platform_data->inst_caps; =20 @@ -391,6 +396,51 @@ static int iris_enum_framesizes(struct file *filp, voi= d *fh, fsize->stepwise.max_height =3D caps->max_frame_height; fsize->stepwise.step_height =3D STEP_HEIGHT; =20 + return ret; +} + +static int iris_enum_frameintervals(struct file *filp, void *fh, + struct v4l2_frmivalenum *fival) + +{ + struct iris_inst *inst =3D iris_get_inst(filp, NULL); + struct platform_inst_caps *caps; + struct iris_core *core =3D inst->core; + u32 fps, mbpf; + int ret =3D 0; + + if (inst->domain =3D=3D DECODER) + return -ENOTTY; + + if (fival->index) + return -EINVAL; + + ret =3D iris_venc_validate_format(inst, fival->pixel_format); + if (ret) + return ret; + + if (!fival->width || !fival->height) + return -EINVAL; + + caps =3D inst->core->iris_platform_data->inst_caps; + if (fival->width > caps->max_frame_width || + fival->width < caps->min_frame_width || + fival->height > caps->max_frame_height || + fival->height < caps->min_frame_height) + return -EINVAL; + + mbpf =3D NUM_MBS_PER_FRAME(fival->height, fival->width); + fps =3D DIV_ROUND_UP(core->iris_platform_data->max_core_mbps, mbpf); + + fival->type =3D V4L2_FRMIVAL_TYPE_STEPWISE; + fival->stepwise.min.numerator =3D 1; + fival->stepwise.min.denominator =3D + min_t(u32, fps, MAXIMUM_FPS); + fival->stepwise.max.numerator =3D 1; + fival->stepwise.max.denominator =3D 1; + fival->stepwise.step.numerator =3D 1; + fival->stepwise.step.denominator =3D MAXIMUM_FPS; + return 0; } =20 @@ -525,6 +575,8 @@ static const struct v4l2_ioctl_ops iris_v4l2_ioctl_ops_= enc =3D { .vidioc_s_fmt_vid_out_mplane =3D iris_s_fmt_vid_mplane, .vidioc_g_fmt_vid_cap_mplane =3D iris_g_fmt_vid_mplane, .vidioc_g_fmt_vid_out_mplane =3D iris_g_fmt_vid_mplane, + .vidioc_enum_framesizes =3D iris_enum_framesizes, + .vidioc_enum_frameintervals =3D iris_enum_frameintervals, }; =20 void iris_init_ops(struct iris_core *core) --=20 2.34.1 From nobody Tue Oct 7 22:51:46 2025 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 6E35A2D12ED; Fri, 4 Jul 2025 07:54:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615665; cv=none; b=mD3B1Vq+QduMXck5xNEIfHIa2fUOxdGl9So5Ve0iYDoAyQkIazIf2zJZdTiSkffTpOce8ho1rqkFoirYEsxDoxl7vXeBBZaafYI1pEXjgzrHUZBxMj6KxFZW+nPNC4lU7BMfdp0bzMDasEIXGlWUaFp4eKg6PUdJzbK9RoQe58s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615665; c=relaxed/simple; bh=HRAOdaZPz4TdXaD50WyBJL6WbKyKNuM01m4aW/p2Eks=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=cKuIA8daxWXy30tLqZ7G6dSjKIBcUW+UTOARW1hBj7gUohSiN7NHvRl6INULIzDB/dkvZ3Ax1QHwYkCENKgdsJ8Auswzm+Ol+wM5tsWCvlsUrWw7fTyxSAz4tNGz6/SaZ0W028t2LDRoOY6Ghv0iQ5z8TCqFU1ebSO87+VEK4tc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=dM63eWzn; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="dM63eWzn" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56464I7j007047; Fri, 4 Jul 2025 07:54:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= ThZ99ENkNRYHQWZj87w7NChFG0hgkn0V9pizxk8AFR0=; b=dM63eWzntPJpox/l inB6L3roRoXzO4l6NcDGQ9bojoCDO4ovPzD4hAkqllWirJNyC2OCrEtqCIINTdaW RdjSU+JTWnQM9tXe1mIzzbXWoU8AaBy2zM6o+3eKNrAIYaQRyxHQew2YVLLyntiZ HesviHjQorTuhFLfgEN26CbxW/AM7sdbujNAkjiHOWAt2cT35+6eVifXzaCxQq3O Ug459NRYnlSFq2AODfGvPLKriqQwQR00LZmNd3TbLRXVvLtyg7QxaoSj/XeuyiXc uHqbd0JCBdf92geQ8gpD/0qlvDUPnQtMN6PkYE+1lNPKFDqcLblenLOaEwOBCbJk fCqNcw== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 47kn5jqgt9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Jul 2025 07:54:17 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA04.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 5647sHo2018461 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 4 Jul 2025 07:54:17 GMT Received: from hu-dikshita-hyd.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Fri, 4 Jul 2025 00:54:14 -0700 From: Dikshita Agarwal Date: Fri, 4 Jul 2025 13:23:16 +0530 Subject: [PATCH 16/25] media: iris: Add support for VIDIOC_QUERYCAP for encoder video device Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20250704-iris-video-encoder-v1-16-b6ce24e273cf@quicinc.com> References: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> In-Reply-To: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> To: Vikash Garodia , Abhinav Kumar , Bryan O'Donoghue , Mauro Carvalho Chehab , Hans Verkuil , Stefan Schmidt , "Vedang Nagar" CC: , , , Dikshita Agarwal X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1751615599; l=1524; i=quic_dikshita@quicinc.com; s=20240917; h=from:subject:message-id; bh=HRAOdaZPz4TdXaD50WyBJL6WbKyKNuM01m4aW/p2Eks=; b=cpEcaouTDmdhSBwrueSrUJVcFOUUIE1ZNWkJaI/iAms8rQoZsodrC9smhi2ltM/FDZubhxk/o NGfkEvqWUgXD2gwtFmGoS2FBZ1nmC8dT+3v7lVao6kZ5QrOjEQkspRs X-Developer-Key: i=quic_dikshita@quicinc.com; a=ed25519; pk=EEvKY6Ar1OI5SWf44FJ1Ebo1KuQEVbbf5UNPO+UHVhM= X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Authority-Analysis: v=2.4 cv=KtJN2XWN c=1 sm=1 tr=0 ts=686788aa cx=c_pps a=JYp8KDb2vCoCEuGobkYCKw==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=GEpy-HfZoHoA:10 a=IkcTkHD0fZMA:10 a=Wb1JkmetP80A:10 a=COk6AnOGAAAA:8 a=-r1po_HhmiMhMH7Jft0A:9 a=QEXdDO2ut3YA:10 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-ORIG-GUID: BHSZCCDpKaWfS8UUfzJlY1OZASIsgUUC X-Proofpoint-GUID: BHSZCCDpKaWfS8UUfzJlY1OZASIsgUUC X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzA0MDA2MCBTYWx0ZWRfX5r0Stazfkq3k XdXzsZDgLwwMhj5MbfGSq7zoxZJRCyKcRW3cRcydNoO7G8HyBCUu+ARsAcHErVM7ySMBcS07V7X OtHHpIUyKLKPQoftspGBFLdW/sHUgdf+Py3GxUG8Itq8D5jWzhRxnEdiz/8nAWfM+TE8eLt3YWz tfr1OFRllFHJeB90Qnw/3pBobtqI5SRP21W9ziNhMbWhiOx3hj13EvDglDTDixlJlxZq5zvAtRa b84TZsOY5iIZ28X1c15u/rxzDDarpKuob07L5XoQ6C3b6VVRUwAIC7LDadxUqrR0pzA6dF8wgZN MIwLCFCW7bJFxEXw8ImQAZtz87o6HOJMs3xI3aqfTdY3bfx7gRVTlldaaGg5ie/9p3iwvDa+JN8 hm2EiUawkxcd9hlNFfN1iL7A9MZR8wwTIwmj4Mz/K0DHlPo51b5VV9HH94PCNSE/+cNY3KI1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-04_03,2025-07-02_04,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 bulkscore=0 priorityscore=1501 malwarescore=0 suspectscore=0 mlxscore=0 spamscore=0 adultscore=0 lowpriorityscore=0 phishscore=0 clxscore=1015 mlxlogscore=999 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507040060 Add support for the VIDIOC_QUERYCAP V4L2 iocts for the encoder video device to report core driver capabilities. Signed-off-by: Dikshita Agarwal Tested-by: Vikash Garodia # X1E80100 --- drivers/media/platform/qcom/iris/iris_vidc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/qcom/iris/iris_vidc.c b/drivers/media/p= latform/qcom/iris/iris_vidc.c index cb1280c0c6c82187243f0bda4d98e42370ee787c..458773a2ed7f5e16d5bd5e79dba= 2f5c029036505 100644 --- a/drivers/media/platform/qcom/iris/iris_vidc.c +++ b/drivers/media/platform/qcom/iris/iris_vidc.c @@ -446,8 +446,14 @@ static int iris_enum_frameintervals(struct file *filp,= void *fh, =20 static int iris_querycap(struct file *filp, void *fh, struct v4l2_capabili= ty *cap) { + struct iris_inst *inst =3D iris_get_inst(filp, NULL); + strscpy(cap->driver, IRIS_DRV_NAME, sizeof(cap->driver)); - strscpy(cap->card, "Iris Decoder", sizeof(cap->card)); + + if (inst->domain =3D=3D DECODER) + strscpy(cap->card, "Iris Decoder", sizeof(cap->card)); + else + strscpy(cap->card, "Iris Encoder", sizeof(cap->card)); =20 return 0; } @@ -577,6 +583,7 @@ static const struct v4l2_ioctl_ops iris_v4l2_ioctl_ops_= enc =3D { .vidioc_g_fmt_vid_out_mplane =3D iris_g_fmt_vid_mplane, .vidioc_enum_framesizes =3D iris_enum_framesizes, .vidioc_enum_frameintervals =3D iris_enum_frameintervals, + .vidioc_querycap =3D iris_querycap, }; =20 void iris_init_ops(struct iris_core *core) --=20 2.34.1 From nobody Tue Oct 7 22:51:46 2025 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 6B1DE2857E9; Fri, 4 Jul 2025 07:54:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615668; cv=none; b=C9UFTXuG/EECcLJhZ+NTZwq6SIrLgaufD6zICz6W0XA11Gs0jU2aZm1ya1nBteerUqV8w3X/wngxAZy+JteVM69KNiWyHP8r4e2pdt/7cEJI/ylujw4dwbmmxHNpjtLkw9dQdNpyr4te4P7XZnAFB792L2NGO4XUxJCjNBtiEeQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615668; c=relaxed/simple; bh=aVSBRYM0dzFACZSMY6AVKuZ0pWWqdJ/B2pGpYaZ0PSw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=gbn84NPBAOMbMKLsFoZ/8VhuAJJ1zaARnYk6zoG3/t9+g5l5cyEwH+nfE3sIBY8ggL+J4PMyHsm+WeBCpYlgkPO57uorUD9q/LVBcdBCBqFp5Kl0Ap/dyO0YIGLSpA/mGdFee5V3lHQ45DnDM0TJ4NdWsYDPsXsnwJkhBsGox6s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=mFEMCNIf; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="mFEMCNIf" Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 563Mwio5022207; Fri, 4 Jul 2025 07:54:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= rBK0U+PPSWwscE7KUwHuHViQLhQP9bEJG4X6O6r4lWs=; b=mFEMCNIfOwMehZqz cF79DFzOQaa34GYEEzo9soDA5Cnn6pcy9+G2aWVAqKOz22AKO2U1oI9l9+hwK3ts BCiZ7l0Z/aQu4aU/5lJujQ43FMwoihoXU9rjKulP9E6kBbzIytuw7uscKNTWqHlu MUfE6mR4fc725jkG5vL7F2VR4MrhY2/jjm7bn9b8kRxfbTUEI34O6NIiGthg3MNq DoqvZMDv4T/Ie+Lpm3cgnbuN7zDlkd5AJCjNSy62te9ayHE6fWRtWfkvO76CJlRA IsaIMx2LRDMa5vDQNuJDxYVzQYSAFjkR5u6v55ObQWssjJW1znQDY12xMYawQTjR HrrZSg== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 47j7bw34wm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Jul 2025 07:54:21 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA03.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 5647sKPB019904 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 4 Jul 2025 07:54:20 GMT Received: from hu-dikshita-hyd.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Fri, 4 Jul 2025 00:54:17 -0700 From: Dikshita Agarwal Date: Fri, 4 Jul 2025 13:23:17 +0530 Subject: [PATCH 17/25] media: iris: Add encoder support for V4L2 event subscription Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20250704-iris-video-encoder-v1-17-b6ce24e273cf@quicinc.com> References: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> In-Reply-To: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> To: Vikash Garodia , Abhinav Kumar , Bryan O'Donoghue , Mauro Carvalho Chehab , Hans Verkuil , Stefan Schmidt , "Vedang Nagar" CC: , , , Dikshita Agarwal X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1751615599; l=3502; i=quic_dikshita@quicinc.com; s=20240917; h=from:subject:message-id; bh=aVSBRYM0dzFACZSMY6AVKuZ0pWWqdJ/B2pGpYaZ0PSw=; b=1fivc1NE9oZFlhdJoF/spQlh2QQj8AFQOZOm2pNzKSA6RSICZNhgVS7tcqw9PdnJW6wgQD7DL e4hPzV6dIviCyL6px05TFyFU+N9BkaKJ24qVB1CEpVp+Kx8maWCm4n5 X-Developer-Key: i=quic_dikshita@quicinc.com; a=ed25519; pk=EEvKY6Ar1OI5SWf44FJ1Ebo1KuQEVbbf5UNPO+UHVhM= X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: N_pfPDwL1STJndBZ1CHAq_eghcnI8H6M X-Authority-Analysis: v=2.4 cv=RJCzH5i+ c=1 sm=1 tr=0 ts=686788ad cx=c_pps a=JYp8KDb2vCoCEuGobkYCKw==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=GEpy-HfZoHoA:10 a=IkcTkHD0fZMA:10 a=Wb1JkmetP80A:10 a=COk6AnOGAAAA:8 a=JXiySR5JOE9jObuYKgMA:9 a=QEXdDO2ut3YA:10 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-ORIG-GUID: N_pfPDwL1STJndBZ1CHAq_eghcnI8H6M X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzA0MDA2MCBTYWx0ZWRfX+NmnEg0Y7vIY BTME2lUs/KyB4KvOdvkmAPMVabgJ/JSQIMbXFytz5AXyBrUQxemnmdnQKxiuirqMX5MkteskY61 UmJ4arOFci/FsL7E/h+kSC0AGnops2Qqxktyo6QKdeoD42RtPelM79X6+nk1n097FXiXLCkEM18 0NwCdLXzy7EqTTa/6oVkjk8+6OT+ZgQaOIROgAGesQKu1ohP5Jmn8AAUwwPoZREsmxAcL3Xd80d f7oIfx+sQYZB4kpknrg/TbOpPIMvBaxIy9ues4PZ2W7X+hhuCn87udzInG3KdpbX4ymRSe8HC5p 9npSreKmyTLatuM8W3AY+Dwwun4rzNsYF0Gv6oOZ0YgDz+5N7sw0nM08n09BLkvJrkUaxi6DPi0 57sdHefkGFcOgWkeuqAXnsVscig/VjvWGflLnyJZPhmunDv97hxERRE7SaLL/8aiCqsRPhPG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-04_03,2025-07-02_04,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 impostorscore=0 priorityscore=1501 mlxlogscore=999 adultscore=0 malwarescore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 phishscore=0 bulkscore=0 suspectscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507040060 Implement support for V4L2 event subscription on the encoder device by handling the SUBSCRIBE_EVENT and UNSUBSCRIBE_EVENT ioctls with the necessary hooks. This enables userspace applications to subscribe to V4L2 events, allowing asynchronous notification mechanisms. Signed-off-by: Dikshita Agarwal Tested-by: Vikash Garodia # X1E80100 --- drivers/media/platform/qcom/iris/iris_venc.c | 14 ++++++++++++++ drivers/media/platform/qcom/iris/iris_venc.h | 1 + drivers/media/platform/qcom/iris/iris_vidc.c | 9 ++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/qcom/iris/iris_venc.c b/drivers/media/p= latform/qcom/iris/iris_venc.c index 301206253090962abbb4e4eac8ee88e7b359c98d..3dbcce23cbe94cf0edc4421694a= 3ba11faa5eb96 100644 --- a/drivers/media/platform/qcom/iris/iris_venc.c +++ b/drivers/media/platform/qcom/iris/iris_venc.c @@ -3,6 +3,7 @@ * Copyright (c) 2022-2025 Qualcomm Innovation Center, Inc. All rights res= erved. */ =20 +#include #include =20 #include "iris_buffer.h" @@ -283,3 +284,16 @@ int iris_venc_validate_format(struct iris_inst *inst, = u32 pixelformat) =20 return 0; } + +int iris_venc_subscribe_event(struct iris_inst *inst, + const struct v4l2_event_subscription *sub) +{ + switch (sub->type) { + case V4L2_EVENT_EOS: + return v4l2_event_subscribe(&inst->fh, sub, 0, NULL); + case V4L2_EVENT_CTRL: + return v4l2_ctrl_subscribe_event(&inst->fh, sub); + default: + return -EINVAL; + } +} diff --git a/drivers/media/platform/qcom/iris/iris_venc.h b/drivers/media/p= latform/qcom/iris/iris_venc.h index 04fd41275547c40c359c6ea04dfe4ee31d2d0df6..2d9614ae18e8a2318df6673fbea= e5ee33c99b596 100644 --- a/drivers/media/platform/qcom/iris/iris_venc.h +++ b/drivers/media/platform/qcom/iris/iris_venc.h @@ -14,5 +14,6 @@ int iris_venc_enum_fmt(struct iris_inst *inst, struct v4l= 2_fmtdesc *f); int iris_venc_try_fmt(struct iris_inst *inst, struct v4l2_format *f); int iris_venc_s_fmt(struct iris_inst *inst, struct v4l2_format *f); int iris_venc_validate_format(struct iris_inst *inst, u32 pixelformat); +int iris_venc_subscribe_event(struct iris_inst *inst, const struct v4l2_ev= ent_subscription *sub); =20 #endif diff --git a/drivers/media/platform/qcom/iris/iris_vidc.c b/drivers/media/p= latform/qcom/iris/iris_vidc.c index 458773a2ed7f5e16d5bd5e79dba2f5c029036505..d8c94074153e9b1ceac4f911210= ddbf89bbe3533 100644 --- a/drivers/media/platform/qcom/iris/iris_vidc.c +++ b/drivers/media/platform/qcom/iris/iris_vidc.c @@ -489,7 +489,12 @@ static int iris_subscribe_event(struct v4l2_fh *fh, co= nst struct v4l2_event_subs { struct iris_inst *inst =3D container_of(fh, struct iris_inst, fh); =20 - return iris_vdec_subscribe_event(inst, sub); + if (inst->domain =3D=3D DECODER) + return iris_vdec_subscribe_event(inst, sub); + else if (inst->domain =3D=3D ENCODER) + return iris_venc_subscribe_event(inst, sub); + + return -EINVAL; } =20 static int iris_dec_cmd(struct file *filp, void *fh, @@ -584,6 +589,8 @@ static const struct v4l2_ioctl_ops iris_v4l2_ioctl_ops_= enc =3D { .vidioc_enum_framesizes =3D iris_enum_framesizes, .vidioc_enum_frameintervals =3D iris_enum_frameintervals, .vidioc_querycap =3D iris_querycap, + .vidioc_subscribe_event =3D iris_subscribe_event, + .vidioc_unsubscribe_event =3D v4l2_event_unsubscribe, }; =20 void iris_init_ops(struct iris_core *core) --=20 2.34.1 From nobody Tue Oct 7 22:51:46 2025 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 D3ACF2D97BE; Fri, 4 Jul 2025 07:54:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615672; cv=none; b=Ri6QsMSl27fSCdKcM0p64LBIPAV4868dHk3639jg4oyJSZc/3vBwZOIz2XudlVn2xZIIHMuP4eN3irj1OnMF0Aunp5AvX/Uqq+jo74Lixgh8LEpIdFl/v13SDUHXrYaRjmx3tj394QIAkGx+17E1Sfk8QE+zsiRPcL8RVzq3Byo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615672; c=relaxed/simple; bh=s5EcbUknkQfTe70BqoXoFc1adqDtlQbwQUL/1RUlW2k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=aSRvKxQ20/FGRckHwA0c8pTiTJ8pkF15z7ysxedZ6u8vKJHA/bDRQdryvLXC9NGbEZycZfFBKQ+/e3ShSD6nbx23qbyIxR+mfGiotB5+DtaR+fNZGOTj+kSNiblUhikDnvcuES9t6QyCPZ+IBUbONl5QzbRCOY5chXgvrACcLTs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=icgw9/5y; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="icgw9/5y" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 563IctQO029572; Fri, 4 Jul 2025 07:54:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= bUAvhVvnBbbYgy9q0mHdzebSgGWDOX2R719IRsy1Ogc=; b=icgw9/5ybqA7/ei2 FqITrI+8NDGHrGpZhfRVuLDtXjgSUWdTsB6Yyz7EOZknQQOTvw4Lfe9llRt6Du9y UigmBh/XOZ95Mnm0EJt57TtDTX/TDZvn2JSHJfHBGSJ7lBtHcldQYfso8PziNr3E mZs+PafU4WMrLqjzEvpqnFpu/18JMQM2VzbXsYjQWP4Qwy3Fh9x6oUy3KFFxs3BF nobkCSlEoGgUzbTeP3zxgVD5O6OpEX92eR/OsUdTpP3N0SYeCCCzrz5D3L7gIkSr 5AhBdjE6b9HqMLRd5H9yjS5zBgKwSirRutgmH5nItFv9fjhf2wA5gwOM7qLniSQZ gxZ/1Q== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 47nh9s4bv9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Jul 2025 07:54:24 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA01.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 5647sO23002082 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 4 Jul 2025 07:54:24 GMT Received: from hu-dikshita-hyd.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Fri, 4 Jul 2025 00:54:20 -0700 From: Dikshita Agarwal Date: Fri, 4 Jul 2025 13:23:18 +0530 Subject: [PATCH 18/25] media: iris: Add support for G/S_SELECTION for encoder video device Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20250704-iris-video-encoder-v1-18-b6ce24e273cf@quicinc.com> References: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> In-Reply-To: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> To: Vikash Garodia , Abhinav Kumar , Bryan O'Donoghue , Mauro Carvalho Chehab , Hans Verkuil , Stefan Schmidt , "Vedang Nagar" CC: , , , Dikshita Agarwal X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1751615599; l=5403; i=quic_dikshita@quicinc.com; s=20240917; h=from:subject:message-id; bh=s5EcbUknkQfTe70BqoXoFc1adqDtlQbwQUL/1RUlW2k=; b=pPLUCcxCPz40tNk/Zu5WqNQqH0IAc4ky00+3VnoEFnyf9Wwe2bBYbjMIrLXs1Zd1rXjzSQyHq vMaaScwzBmuCtumpXJz+205T6wM+cDNnKAGINLgPMfXVMKGZ5MVQ3OP X-Developer-Key: i=quic_dikshita@quicinc.com; a=ed25519; pk=EEvKY6Ar1OI5SWf44FJ1Ebo1KuQEVbbf5UNPO+UHVhM= X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Authority-Analysis: v=2.4 cv=frrcZE4f c=1 sm=1 tr=0 ts=686788b0 cx=c_pps a=JYp8KDb2vCoCEuGobkYCKw==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=GEpy-HfZoHoA:10 a=IkcTkHD0fZMA:10 a=Wb1JkmetP80A:10 a=COk6AnOGAAAA:8 a=HMXTeDd-yh4hRLGjqV0A:9 a=QEXdDO2ut3YA:10 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzA0MDA2MCBTYWx0ZWRfX0wbFOIm2ygyv vQKv1PsELq/Ma4Ss5K8K5w2cPwthIr4ECqTznfHPcK/ZIhC7FPEKx34IUKLplomXvZy2Z9mw1JA ELWPK6zsCKlNbvSgK4Vg1MvKnSvNww9FrwCIhoD2PbaYli3r8qMBtJCaeb27aQt+WJmt6LvtaQG q0/hXKiFLlUpowy2y5hUADvuxLBjS78vE08HI3jvUyClUTmTFlAjUsotZw8K7aBZOY4O9KSlaDn lArN6IeDTvuMo+0NeI/moDXJgIYWIotuuWFEUOYqSIw6fSzdExysQXiHqB7IAkBf1vpy8xjdA6P qkX5qoAt1Lo7bEOPRRcXfvIXXJAkSAOP/ndAPIAEQW5Ss32p5xxlEjPL5UlwL33GYO7SzKGEeek 55XyIvnpNV2kwQolj+6q2UO4fVchQOa7EU2nfdxg41QCoS0utC+I6ZPdvtqHniO2+nrcf8om X-Proofpoint-GUID: pOqOPl39xmFrlXKIve8JuIZfMvkzq0yb X-Proofpoint-ORIG-GUID: pOqOPl39xmFrlXKIve8JuIZfMvkzq0yb X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-04_03,2025-07-02_04,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxlogscore=999 bulkscore=0 spamscore=0 adultscore=0 impostorscore=0 clxscore=1015 lowpriorityscore=0 suspectscore=0 mlxscore=0 priorityscore=1501 malwarescore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507040060 Add support for G/S_SELECTION V4L2 ioctls for the encoder video device with necessary hooks. This allows userspace to query and configure rectangular selection areas such as crop. Signed-off-by: Dikshita Agarwal Tested-by: Vikash Garodia # X1E80100 --- drivers/media/platform/qcom/iris/iris_venc.c | 28 ++++++++++++ drivers/media/platform/qcom/iris/iris_venc.h | 1 + drivers/media/platform/qcom/iris/iris_vidc.c | 65 ++++++++++++++++++++++--= ---- 3 files changed, 80 insertions(+), 14 deletions(-) diff --git a/drivers/media/platform/qcom/iris/iris_venc.c b/drivers/media/p= latform/qcom/iris/iris_venc.c index 3dbcce23cbe94cf0edc4421694a3ba11faa5eb96..930f5afe9489d01be193f1dbe42= 9d33f5401b468 100644 --- a/drivers/media/platform/qcom/iris/iris_venc.c +++ b/drivers/media/platform/qcom/iris/iris_venc.c @@ -297,3 +297,31 @@ int iris_venc_subscribe_event(struct iris_inst *inst, return -EINVAL; } } + +int iris_venc_s_selection(struct iris_inst *inst, struct v4l2_selection *s) +{ + if (s->type !=3D V4L2_BUF_TYPE_VIDEO_OUTPUT) + return -EINVAL; + + switch (s->target) { + case V4L2_SEL_TGT_CROP: + s->r.left =3D 0; + s->r.top =3D 0; + + if (s->r.width > inst->fmt_src->fmt.pix_mp.width || + s->r.height > inst->fmt_src->fmt.pix_mp.height) + return -EINVAL; + + inst->crop.left =3D s->r.left; + inst->crop.top =3D s->r.top; + inst->crop.width =3D s->r.width; + inst->crop.height =3D s->r.height; + inst->fmt_dst->fmt.pix_mp.width =3D inst->crop.width; + inst->fmt_dst->fmt.pix_mp.height =3D inst->crop.height; + return iris_venc_s_fmt_output(inst, inst->fmt_dst); + default: + return -EINVAL; + } + + return 0; +} diff --git a/drivers/media/platform/qcom/iris/iris_venc.h b/drivers/media/p= latform/qcom/iris/iris_venc.h index 2d9614ae18e8a2318df6673fbeae5ee33c99b596..72c6e25d87113baa6d2219ae478= b7d7df1aed7bf 100644 --- a/drivers/media/platform/qcom/iris/iris_venc.h +++ b/drivers/media/platform/qcom/iris/iris_venc.h @@ -15,5 +15,6 @@ int iris_venc_try_fmt(struct iris_inst *inst, struct v4l2= _format *f); int iris_venc_s_fmt(struct iris_inst *inst, struct v4l2_format *f); int iris_venc_validate_format(struct iris_inst *inst, u32 pixelformat); int iris_venc_subscribe_event(struct iris_inst *inst, const struct v4l2_ev= ent_subscription *sub); +int iris_venc_s_selection(struct iris_inst *inst, struct v4l2_selection *s= ); =20 #endif diff --git a/drivers/media/platform/qcom/iris/iris_vidc.c b/drivers/media/p= latform/qcom/iris/iris_vidc.c index d8c94074153e9b1ceac4f911210ddbf89bbe3533..2074682a35fd1c4c9f5d29fdaee= 3392d98bf8923 100644 --- a/drivers/media/platform/qcom/iris/iris_vidc.c +++ b/drivers/media/platform/qcom/iris/iris_vidc.c @@ -462,29 +462,64 @@ static int iris_g_selection(struct file *filp, void *= fh, struct v4l2_selection * { struct iris_inst *inst =3D iris_get_inst(filp, NULL); =20 - if (s->type !=3D V4L2_BUF_TYPE_VIDEO_CAPTURE) + if (s->type !=3D V4L2_BUF_TYPE_VIDEO_CAPTURE && + inst->domain =3D=3D DECODER) return -EINVAL; =20 - switch (s->target) { - case V4L2_SEL_TGT_CROP_BOUNDS: - case V4L2_SEL_TGT_CROP_DEFAULT: - case V4L2_SEL_TGT_CROP: - case V4L2_SEL_TGT_COMPOSE_BOUNDS: - case V4L2_SEL_TGT_COMPOSE_PADDED: - case V4L2_SEL_TGT_COMPOSE_DEFAULT: - case V4L2_SEL_TGT_COMPOSE: + if (s->type !=3D V4L2_BUF_TYPE_VIDEO_OUTPUT && + inst->domain =3D=3D ENCODER) + return -EINVAL; + + if (inst->domain =3D=3D DECODER) { + switch (s->target) { + case V4L2_SEL_TGT_CROP_BOUNDS: + case V4L2_SEL_TGT_CROP_DEFAULT: + case V4L2_SEL_TGT_CROP: + case V4L2_SEL_TGT_COMPOSE_BOUNDS: + case V4L2_SEL_TGT_COMPOSE_PADDED: + case V4L2_SEL_TGT_COMPOSE_DEFAULT: + case V4L2_SEL_TGT_COMPOSE: + s->r.left =3D inst->crop.left; + s->r.top =3D inst->crop.top; + s->r.width =3D inst->crop.width; + s->r.height =3D inst->crop.height; + break; + default: + return -EINVAL; + } + } else if (inst->domain =3D=3D ENCODER) { + switch (s->target) { + case V4L2_SEL_TGT_CROP_BOUNDS: + case V4L2_SEL_TGT_CROP_DEFAULT: + s->r.width =3D inst->fmt_src->fmt.pix_mp.width; + s->r.height =3D inst->fmt_src->fmt.pix_mp.height; + break; + case V4L2_SEL_TGT_CROP: + s->r.width =3D inst->crop.width; + s->r.height =3D inst->crop.height; + break; + default: + return -EINVAL; + } s->r.left =3D inst->crop.left; s->r.top =3D inst->crop.top; - s->r.width =3D inst->crop.width; - s->r.height =3D inst->crop.height; - break; - default: - return -EINVAL; } =20 return 0; } =20 +static int iris_s_selection(struct file *filp, void *fh, struct v4l2_selec= tion *s) +{ + struct iris_inst *inst =3D iris_get_inst(filp, NULL); + + if (inst->domain =3D=3D DECODER) + return -EINVAL; + else if (inst->domain =3D=3D ENCODER) + return iris_venc_s_selection(inst, s); + + return -EINVAL; +} + static int iris_subscribe_event(struct v4l2_fh *fh, const struct v4l2_even= t_subscription *sub) { struct iris_inst *inst =3D container_of(fh, struct iris_inst, fh); @@ -591,6 +626,8 @@ static const struct v4l2_ioctl_ops iris_v4l2_ioctl_ops_= enc =3D { .vidioc_querycap =3D iris_querycap, .vidioc_subscribe_event =3D iris_subscribe_event, .vidioc_unsubscribe_event =3D v4l2_event_unsubscribe, + .vidioc_g_selection =3D iris_g_selection, + .vidioc_s_selection =3D iris_s_selection, }; =20 void iris_init_ops(struct iris_core *core) --=20 2.34.1 From nobody Tue Oct 7 22:51:46 2025 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 B57422DCF5F; Fri, 4 Jul 2025 07:54:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615676; cv=none; b=ToJSUzmGnXBy389v1A8q+RzlZfpAldhZlQ8iVIN+X0A/8uzOYjuZgCQIUTwG5z9PHdzCIgJQ6yY231zRV7lK3FB4iCbQ1n+jHIwGH/uUNulr3+lPSyEPWJebQIJTNZ9eaI/Db7gm+bNEqP34oi1641rJcEmMLQAJUCN9URbakqI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615676; c=relaxed/simple; bh=CqdJ4L2WbOiS+sHZ0cpXwSoO8hzZnM/ky7dDlVdxoPM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=LHZZRvgRL3eV02YrYFJGtEfr699zZy5NEKMzBuyRl7QX8HFs/a+OQ2uLUZ8UdT4J8scOQidQQ8GN4C/r18DM+hKaiVUVoFcgmGPo1cmwO2ji0mcp3996NKuO2MtB9oXzR74CiakmXb9q1/kjhpVyPP1kbNwbR1U4mLiyGHa+kzI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=iupJDFPg; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="iupJDFPg" Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5644NNU7003315; Fri, 4 Jul 2025 07:54:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= 8rXSCe/otDLiBBoQSFTMZ+pfZF515wQlRYd+g5VHd4M=; b=iupJDFPg/+ndUXOf X2zgGh/xmwza0OikcPG/wQkl8fbHVKNPA8NG7sm0jL9h/jCM2GTvQJ/3LtJJEJZ1 v4q3qjyVYZDssZttR/1xWEHS5FdpNbcT7rMhqq2hns2aUsfKScX86qKxzfSf/1a2 nazQEkK/1DCv1/3xBdg1G3KKIgfe52dbnhVHMOyo9qc8/wzeqMeCO/1jE14DD+XY eUSNlsijWAGr02hLwhnL1VxcNgRubzzLdN0cFkfMfRcWHX9Ts1tu6ADUyWECsWVF LkjxAiMnvKOk81O8pBobB4nSsQBRsiVF9cwQGS5+pfLH622qWOh6D1dfriGA7uKV ZtVO5g== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 47p7ut0ghc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Jul 2025 07:54:28 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA01.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 5647sRrU002140 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 4 Jul 2025 07:54:27 GMT Received: from hu-dikshita-hyd.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Fri, 4 Jul 2025 00:54:24 -0700 From: Dikshita Agarwal Date: Fri, 4 Jul 2025 13:23:19 +0530 Subject: [PATCH 19/25] media: iris: Add support for G/S_PARM for encoder video device Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20250704-iris-video-encoder-v1-19-b6ce24e273cf@quicinc.com> References: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> In-Reply-To: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> To: Vikash Garodia , Abhinav Kumar , Bryan O'Donoghue , Mauro Carvalho Chehab , Hans Verkuil , Stefan Schmidt , "Vedang Nagar" CC: , , , Dikshita Agarwal X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1751615599; l=13775; i=quic_dikshita@quicinc.com; s=20240917; h=from:subject:message-id; bh=CqdJ4L2WbOiS+sHZ0cpXwSoO8hzZnM/ky7dDlVdxoPM=; b=kiR18/njTDKXG4LW3RutsWeGg2/8OF/Pstrwl7rsJPo/5nilNlJAATCEfsey7CBw7g0vh9x9H GgtLPpSoaXlBTb3wX99ApB2cwUZkov6Jdmd40N0DVf5jfN+wkM17kXU X-Developer-Key: i=quic_dikshita@quicinc.com; a=ed25519; pk=EEvKY6Ar1OI5SWf44FJ1Ebo1KuQEVbbf5UNPO+UHVhM= X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzA0MDA2MCBTYWx0ZWRfX+6Vc8ACWduek 2r8uLJa78zxHdtTTd/2iyN7S5U2giBeLZDH5aWhOmrlCR+VpcH0d/RFQqw/dG32x60u4YAuCo9C eOWQDV0KXxsIyeI3Zxw/s9uHTeWoOkBz4prng1H2kZgHTBaCM7KU591o/WS1U83uOOotpRqjF1u Sd8BZYRiIL5yeV1EIkCFiltjE/jCOhx7NeJ2wzGgbI4Wg4URR7YEFKGHmPSv5Q00l22xkEOR2BA 3ILoU4nehknpBNroFtxNbIx1zLCeb6FJPt7O+F6WNzkFcAvZHvXgnX5VQmUTb+GVtn52Jd80lZ9 ASk774rdHxxb+0hqcGctwc3yaEcoQshr2iqrWJlr2CYk/pDxMhioIlCZpq3fQ1LWU6r+7HM37F9 4kzyqNG6nk+ZFC72VLbtCh7fW7HgiQmFLQds20l8gEs93DbdWNkvxuSkvbLS/yLLfAISptN4 X-Proofpoint-GUID: IOdYdm4wocDr0X3Ejfq26kx0bJ-0uFI9 X-Authority-Analysis: v=2.4 cv=Ncfm13D4 c=1 sm=1 tr=0 ts=686788b4 cx=c_pps a=JYp8KDb2vCoCEuGobkYCKw==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=GEpy-HfZoHoA:10 a=IkcTkHD0fZMA:10 a=Wb1JkmetP80A:10 a=COk6AnOGAAAA:8 a=PWobvjESsZjX4MKKfcUA:9 a=QEXdDO2ut3YA:10 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-ORIG-GUID: IOdYdm4wocDr0X3Ejfq26kx0bJ-0uFI9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-04_03,2025-07-02_04,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 bulkscore=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 suspectscore=0 priorityscore=1501 mlxlogscore=999 spamscore=0 malwarescore=0 adultscore=0 mlxscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507040060 Add supports for the G/S_PARM V4L2 ioctls for encoder video device with necessary hooks. This allows userspace to query the current streaming parameters such as frame intervals and set desired streaming parameters primarily the frame rate. Signed-off-by: Dikshita Agarwal Tested-by: Vikash Garodia # X1E80100 --- drivers/media/platform/qcom/iris/iris_instance.h | 5 ++ .../platform/qcom/iris/iris_platform_common.h | 2 + .../media/platform/qcom/iris/iris_platform_gen2.c | 4 +- .../platform/qcom/iris/iris_platform_qcs8300.h | 2 + .../platform/qcom/iris/iris_platform_sm8250.c | 2 + drivers/media/platform/qcom/iris/iris_utils.c | 36 ++++++++ drivers/media/platform/qcom/iris/iris_utils.h | 2 + drivers/media/platform/qcom/iris/iris_vb2.c | 17 ---- drivers/media/platform/qcom/iris/iris_venc.c | 95 ++++++++++++++++++= ++++ drivers/media/platform/qcom/iris/iris_venc.h | 2 + drivers/media/platform/qcom/iris/iris_vidc.c | 30 +++++++ 11 files changed, 179 insertions(+), 18 deletions(-) diff --git a/drivers/media/platform/qcom/iris/iris_instance.h b/drivers/med= ia/platform/qcom/iris/iris_instance.h index 55cf9702111829ef24189986ba5245c7684bfe11..b75549718df3c87cd85aecfc74c= 873c60cd4bde5 100644 --- a/drivers/media/platform/qcom/iris/iris_instance.h +++ b/drivers/media/platform/qcom/iris/iris_instance.h @@ -61,6 +61,9 @@ struct iris_fmt { * @metadata_idx: index for metadata buffer * @codec: codec type * @last_buffer_dequeued: a flag to indicate that last buffer is sent by d= river + * @frame_rate: frame rate of current instance + * @operating_rate: operating rate of current instance + */ =20 struct iris_inst { @@ -96,6 +99,8 @@ struct iris_inst { u32 metadata_idx; u32 codec; bool last_buffer_dequeued; + u32 frame_rate; + u32 operating_rate; }; =20 #endif diff --git a/drivers/media/platform/qcom/iris/iris_platform_common.h b/driv= ers/media/platform/qcom/iris/iris_platform_common.h index 792f46e2e34fd564a1ed61523f72826fc8f74582..d0b84c93aef409b51a767ba11f9= 1c6ce2533f27f 100644 --- a/drivers/media/platform/qcom/iris/iris_platform_common.h +++ b/drivers/media/platform/qcom/iris/iris_platform_common.h @@ -79,6 +79,8 @@ struct platform_inst_caps { u32 mb_cycles_fw; u32 mb_cycles_fw_vpp; u32 num_comv; + u32 max_frame_rate; + u32 max_operating_rate; }; =20 enum platform_inst_fw_cap_type { diff --git a/drivers/media/platform/qcom/iris/iris_platform_gen2.c b/driver= s/media/platform/qcom/iris/iris_platform_gen2.c index 1e2fadfe17672029b46e07ce00a8e31e0711fd58..e047fb75a99a6372dac4ad029ba= ea16034cac633 100644 --- a/drivers/media/platform/qcom/iris/iris_platform_gen2.c +++ b/drivers/media/platform/qcom/iris/iris_platform_gen2.c @@ -209,6 +209,8 @@ static struct platform_inst_caps platform_inst_cap_sm85= 50 =3D { .mb_cycles_fw =3D 489583, .mb_cycles_fw_vpp =3D 66234, .num_comv =3D 0, + .max_frame_rate =3D MAXIMUM_FPS << 16, + .max_operating_rate =3D MAXIMUM_FPS << 16, }; =20 static void iris_set_sm8550_preset_registers(struct iris_core *core) @@ -502,7 +504,7 @@ struct iris_platform_data qcs8300_data =3D { .num_vpp_pipe =3D 2, .max_session_count =3D 16, .max_core_mbpf =3D ((4096 * 2176) / 256) * 4, - .max_core_mbps =3D ((7680 * 4320) / 256) * 60, //TODO confirm!! + .max_core_mbps =3D (((3840 * 2176) / 256) * 120), .input_config_params_default =3D sm8550_vdec_input_config_params_default, .input_config_params_default_size =3D diff --git a/drivers/media/platform/qcom/iris/iris_platform_qcs8300.h b/dri= vers/media/platform/qcom/iris/iris_platform_qcs8300.h index a8d66ed388a34e6bb45d4a089d981bb7d135fb50..22e485b0b2ae8f110d2f3b817e2= 02d1aa7d227fd 100644 --- a/drivers/media/platform/qcom/iris/iris_platform_qcs8300.h +++ b/drivers/media/platform/qcom/iris/iris_platform_qcs8300.h @@ -197,4 +197,6 @@ static struct platform_inst_caps platform_inst_cap_qcs8= 300 =3D { .mb_cycles_fw =3D 326389, .mb_cycles_fw_vpp =3D 44156, .num_comv =3D 0, + .max_frame_rate =3D MAXIMUM_FPS << 16, + .max_operating_rate =3D MAXIMUM_FPS << 16, }; diff --git a/drivers/media/platform/qcom/iris/iris_platform_sm8250.c b/driv= ers/media/platform/qcom/iris/iris_platform_sm8250.c index 2a3cbe1f2d4b27d3cce9e9cdad1525801d71a041..5d59a5a3172a510b3a38f7c9c29= dffd919fafce7 100644 --- a/drivers/media/platform/qcom/iris/iris_platform_sm8250.c +++ b/drivers/media/platform/qcom/iris/iris_platform_sm8250.c @@ -40,6 +40,8 @@ static struct platform_inst_caps platform_inst_cap_sm8250= =3D { .max_mbpf =3D 138240, .mb_cycles_vsp =3D 25, .mb_cycles_vpp =3D 200, + .max_frame_rate =3D MAXIMUM_FPS << 16, + .max_operating_rate =3D MAXIMUM_FPS << 16, }; =20 static void iris_set_sm8250_preset_registers(struct iris_core *core) diff --git a/drivers/media/platform/qcom/iris/iris_utils.c b/drivers/media/= platform/qcom/iris/iris_utils.c index 83c70d6a2d9092615dcf1b7d0fc85110f0df1aa0..f0af926879d5d90c56222aa8d48= 998a34be1c636 100644 --- a/drivers/media/platform/qcom/iris/iris_utils.c +++ b/drivers/media/platform/qcom/iris/iris_utils.c @@ -88,3 +88,39 @@ struct iris_inst *iris_get_instance(struct iris_core *co= re, u32 session_id) mutex_unlock(&core->lock); return NULL; } + +int iris_check_core_mbpf(struct iris_inst *inst) +{ + struct iris_core *core =3D inst->core; + struct iris_inst *instance; + u32 total_mbpf =3D 0; + + mutex_lock(&core->lock); + list_for_each_entry(instance, &core->instances, list) + total_mbpf +=3D iris_get_mbpf(instance); + mutex_unlock(&core->lock); + + if (total_mbpf > core->iris_platform_data->max_core_mbpf) + return -ENOMEM; + + return 0; +} + +int iris_check_core_mbps(struct iris_inst *inst) +{ + struct iris_core *core =3D inst->core; + struct iris_inst *instance; + u32 total_mbps =3D 0, fps =3D 0; + + mutex_lock(&core->lock); + list_for_each_entry(instance, &core->instances, list) { + fps =3D max(instance->frame_rate >> 16, instance->operating_rate >> 16); + total_mbps +=3D iris_get_mbpf(instance) * fps; + } + mutex_unlock(&core->lock); + + if (total_mbps > core->iris_platform_data->max_core_mbps) + return -ENOMEM; + + return 0; +} diff --git a/drivers/media/platform/qcom/iris/iris_utils.h b/drivers/media/= platform/qcom/iris/iris_utils.h index 49869cf7a376880a026f44ff3883a6b13c6fcfbb..75740181122f5bdf93d64d3f43b= 3a26a9fe97919 100644 --- a/drivers/media/platform/qcom/iris/iris_utils.h +++ b/drivers/media/platform/qcom/iris/iris_utils.h @@ -49,5 +49,7 @@ struct iris_inst *iris_get_instance(struct iris_core *cor= e, u32 session_id); void iris_helper_buffers_done(struct iris_inst *inst, unsigned int type, enum vb2_buffer_state state); int iris_wait_for_session_response(struct iris_inst *inst, bool is_flush); +int iris_check_core_mbpf(struct iris_inst *inst); +int iris_check_core_mbps(struct iris_inst *inst); =20 #endif diff --git a/drivers/media/platform/qcom/iris/iris_vb2.c b/drivers/media/pl= atform/qcom/iris/iris_vb2.c index e62ed7a57df2debf0a930ad8307e6d945f589922..e32f7e1f007228a3b2b51cd76cd= 193d852f16080 100644 --- a/drivers/media/platform/qcom/iris/iris_vb2.c +++ b/drivers/media/platform/qcom/iris/iris_vb2.c @@ -12,23 +12,6 @@ #include "iris_vdec.h" #include "iris_power.h" =20 -static int iris_check_core_mbpf(struct iris_inst *inst) -{ - struct iris_core *core =3D inst->core; - struct iris_inst *instance; - u32 total_mbpf =3D 0; - - mutex_lock(&core->lock); - list_for_each_entry(instance, &core->instances, list) - total_mbpf +=3D iris_get_mbpf(instance); - mutex_unlock(&core->lock); - - if (total_mbpf > core->iris_platform_data->max_core_mbpf) - return -ENOMEM; - - return 0; -} - static int iris_check_inst_mbpf(struct iris_inst *inst) { struct platform_inst_caps *caps; diff --git a/drivers/media/platform/qcom/iris/iris_venc.c b/drivers/media/p= latform/qcom/iris/iris_venc.c index 930f5afe9489d01be193f1dbe429d33f5401b468..11666f40a4d1c34e1b6eca0b5e4= 0e0f09eeb2b67 100644 --- a/drivers/media/platform/qcom/iris/iris_venc.c +++ b/drivers/media/platform/qcom/iris/iris_venc.c @@ -58,6 +58,9 @@ int iris_venc_inst_init(struct iris_inst *inst) inst->crop.width =3D f->fmt.pix_mp.width; inst->crop.height =3D f->fmt.pix_mp.height; =20 + inst->operating_rate =3D DEFAULT_FPS << 16; + inst->frame_rate =3D DEFAULT_FPS << 16; + return 0; } =20 @@ -325,3 +328,95 @@ int iris_venc_s_selection(struct iris_inst *inst, stru= ct v4l2_selection *s) =20 return 0; } + +int iris_venc_s_param(struct iris_inst *inst, struct v4l2_streamparm *s_pa= rm) +{ + struct platform_inst_caps *caps =3D inst->core->iris_platform_data->inst_= caps; + struct vb2_queue *src_q =3D v4l2_m2m_get_src_vq(inst->m2m_ctx); + struct vb2_queue *dst_q =3D v4l2_m2m_get_dst_vq(inst->m2m_ctx); + struct v4l2_fract *timeperframe =3D NULL; + u32 default_rate =3D DEFAULT_FPS; + bool is_frame_rate =3D false; + u32 q16_rate, max_rate; + u64 us_per_frame, fps; + int ret =3D 0; + + if (s_parm->type =3D=3D V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { + timeperframe =3D &s_parm->parm.output.timeperframe; + max_rate =3D caps->max_operating_rate >> 16; + s_parm->parm.output.capability =3D V4L2_CAP_TIMEPERFRAME; + } else { + timeperframe =3D &s_parm->parm.capture.timeperframe; + is_frame_rate =3D true; + max_rate =3D caps->max_frame_rate >> 16; + s_parm->parm.capture.capability =3D V4L2_CAP_TIMEPERFRAME; + } + + if (!timeperframe->denominator || !timeperframe->numerator) { + if (!timeperframe->numerator) + timeperframe->numerator =3D 1; + if (!timeperframe->denominator) + timeperframe->denominator =3D default_rate; + } + + us_per_frame =3D timeperframe->numerator * (u64)USEC_PER_SEC; + do_div(us_per_frame, timeperframe->denominator); + + if (!us_per_frame) + return -EINVAL; + + fps =3D (u64)USEC_PER_SEC; + do_div(fps, us_per_frame); + ret =3D fps > max_rate; + if (ret) { + ret =3D -ENOMEM; + goto reset_rate; + } + + q16_rate =3D (u32)fps << 16; + if (is_frame_rate) + inst->frame_rate =3D q16_rate; + else + inst->operating_rate =3D q16_rate; + + if ((s_parm->type =3D=3D V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE && vb2_is_stre= aming(src_q)) || + (s_parm->type =3D=3D V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE && vb2_is_str= eaming(dst_q))) { + ret =3D iris_check_core_mbpf(inst); + if (ret) + goto reset_rate; + ret =3D iris_check_core_mbps(inst); + if (ret) + goto reset_rate; + } + + return 0; + +reset_rate: + if (ret) { + if (is_frame_rate) + inst->frame_rate =3D default_rate << 16; + else + inst->operating_rate =3D default_rate << 16; + } + + return ret; +} + +int iris_venc_g_param(struct iris_inst *inst, struct v4l2_streamparm *s_pa= rm) +{ + struct v4l2_fract *timeperframe =3D NULL; + + if (s_parm->type =3D=3D V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { + timeperframe =3D &s_parm->parm.output.timeperframe; + timeperframe->numerator =3D 1; + timeperframe->denominator =3D inst->operating_rate >> 16; + s_parm->parm.output.capability =3D V4L2_CAP_TIMEPERFRAME; + } else { + timeperframe =3D &s_parm->parm.capture.timeperframe; + timeperframe->numerator =3D 1; + timeperframe->denominator =3D inst->frame_rate >> 16; + s_parm->parm.capture.capability =3D V4L2_CAP_TIMEPERFRAME; + } + + return 0; +} diff --git a/drivers/media/platform/qcom/iris/iris_venc.h b/drivers/media/p= latform/qcom/iris/iris_venc.h index 72c6e25d87113baa6d2219ae478b7d7df1aed7bf..0d566b7fc89b96b8fbc62a35b2b= a795ca0bcf460 100644 --- a/drivers/media/platform/qcom/iris/iris_venc.h +++ b/drivers/media/platform/qcom/iris/iris_venc.h @@ -16,5 +16,7 @@ int iris_venc_s_fmt(struct iris_inst *inst, struct v4l2_f= ormat *f); int iris_venc_validate_format(struct iris_inst *inst, u32 pixelformat); int iris_venc_subscribe_event(struct iris_inst *inst, const struct v4l2_ev= ent_subscription *sub); int iris_venc_s_selection(struct iris_inst *inst, struct v4l2_selection *s= ); +int iris_venc_g_param(struct iris_inst *inst, struct v4l2_streamparm *s_pa= rm); +int iris_venc_s_param(struct iris_inst *inst, struct v4l2_streamparm *s_pa= rm); =20 #endif diff --git a/drivers/media/platform/qcom/iris/iris_vidc.c b/drivers/media/p= latform/qcom/iris/iris_vidc.c index 2074682a35fd1c4c9f5d29fdaee3392d98bf8923..4c11cdac19f97d08a9e6242eea7= 4649aad0242cf 100644 --- a/drivers/media/platform/qcom/iris/iris_vidc.c +++ b/drivers/media/platform/qcom/iris/iris_vidc.c @@ -532,6 +532,34 @@ static int iris_subscribe_event(struct v4l2_fh *fh, co= nst struct v4l2_event_subs return -EINVAL; } =20 +static int iris_s_parm(struct file *filp, void *fh, struct v4l2_streamparm= *a) +{ + struct iris_inst *inst =3D container_of(fh, struct iris_inst, fh); + + if (a->type !=3D V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE && + a->type !=3D V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) + return -EINVAL; + + if (inst->domain =3D=3D ENCODER) + return iris_venc_s_param(inst, a); + else + return -EINVAL; +} + +static int iris_g_parm(struct file *filp, void *fh, struct v4l2_streamparm= *a) +{ + struct iris_inst *inst =3D container_of(fh, struct iris_inst, fh); + + if (a->type !=3D V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE && + a->type !=3D V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) + return -EINVAL; + + if (inst->domain =3D=3D ENCODER) + return iris_venc_g_param(inst, a); + else + return -EINVAL; +} + static int iris_dec_cmd(struct file *filp, void *fh, struct v4l2_decoder_cmd *dec) { @@ -628,6 +656,8 @@ static const struct v4l2_ioctl_ops iris_v4l2_ioctl_ops_= enc =3D { .vidioc_unsubscribe_event =3D v4l2_event_unsubscribe, .vidioc_g_selection =3D iris_g_selection, .vidioc_s_selection =3D iris_s_selection, + .vidioc_s_parm =3D iris_s_parm, + .vidioc_g_parm =3D iris_g_parm, }; =20 void iris_init_ops(struct iris_core *core) --=20 2.34.1 From nobody Tue Oct 7 22:51:46 2025 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 7CF162E11D9; Fri, 4 Jul 2025 07:54:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615684; cv=none; b=ghCuOESemG71D0RpbrwEPxYlH130qaS2A56pYBUALNNvtfw6RmEicjz92v0JTihG01iEzR/jl3TuyVoaUca6m18TmWy8sOTkGowMCybHidtf8Zx+L2DhpPVzYwCJqTC5TyymWgYK9qSh+MCgwIx/kw5ud5TDgn6WDYP7kJkopYc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615684; c=relaxed/simple; bh=SM6B09cEtLr0cQW3/wslUhcw6mhZD/RfYeYb2WABNkg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=qxxQwu6pN96lMLDWfodTn+IdYYWvcuIuBnDoEam2y0wKJS4OvLntiXHvKC+yT1xik6sCF/lQbedBW/Evq7OTjMYgMYSxOHkJ5TRFi0CjsGDwgv3jmR4AiIrR6PVqP9YUX9bDfjq506xsCs317vYORCVx+Oh7bts0AYGrWWEfo9s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=EO9Qz/9R; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="EO9Qz/9R" Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56467jRI028627; Fri, 4 Jul 2025 07:54:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= Xh6OWGtiWQgLaDZ2BaY7HS7ssnTCySoBxOxcFfoCiKY=; b=EO9Qz/9R54UyUJw8 G/hpImVlX9ODKvU6hMzM7Nj8orpF+z5PHjOanle+6yfp+zUtlRonp4NeprmMM8/+ W38Pdw2tCTIlbETLzvowvDEaYgAJGtjUcVI0kAx8CrxncLMdg1j120ul4eBNe04z ijcvwDLHXnHaFpvvvi4ThTBgPmB5S18RrBHhMbBDGsl1fGjgnmF6+0My7egmK8yE Kj+vuLm4FqZdh+9zwbST4AL90iFtWzwrTvc1/4vMtjvGcVRXQZQxardnwaTemd/W pJdyPKR+RwlcH55mUPjLClxGYZeM+6tTlASCJ7spTelzixehyHN4uQBUS7jhnOM9 ldXRoA== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 47j7bw34xf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Jul 2025 07:54:31 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA05.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 5647sVqZ025827 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 4 Jul 2025 07:54:31 GMT Received: from hu-dikshita-hyd.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Fri, 4 Jul 2025 00:54:27 -0700 From: Dikshita Agarwal Date: Fri, 4 Jul 2025 13:23:20 +0530 Subject: [PATCH 20/25] media: iris: Add platform-specific capabilities for encoder video device Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20250704-iris-video-encoder-v1-20-b6ce24e273cf@quicinc.com> References: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> In-Reply-To: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> To: Vikash Garodia , Abhinav Kumar , Bryan O'Donoghue , Mauro Carvalho Chehab , Hans Verkuil , Stefan Schmidt , "Vedang Nagar" CC: , , , Dikshita Agarwal X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1751615599; l=47902; i=quic_dikshita@quicinc.com; s=20240917; h=from:subject:message-id; bh=SM6B09cEtLr0cQW3/wslUhcw6mhZD/RfYeYb2WABNkg=; b=v8tZivfsu6uarc2h17mez2VoZPDZqm5vCltJcSeRmEX+9iyN757/evWcBQdejV6nkSHKn68oB MhsGwDBmxb6Ba5GQ3UTki9NJZd+GyUy/DERIOv6ZsBuZqdsWZSp6Tdy X-Developer-Key: i=quic_dikshita@quicinc.com; a=ed25519; pk=EEvKY6Ar1OI5SWf44FJ1Ebo1KuQEVbbf5UNPO+UHVhM= X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: 6t63fY6GMGZwHKhP_LsNvOZcovC_IXpU X-Authority-Analysis: v=2.4 cv=RJCzH5i+ c=1 sm=1 tr=0 ts=686788b7 cx=c_pps a=JYp8KDb2vCoCEuGobkYCKw==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=GEpy-HfZoHoA:10 a=IkcTkHD0fZMA:10 a=Wb1JkmetP80A:10 a=COk6AnOGAAAA:8 a=ScKKUSS3TOtuzMhYn2MA:9 a=QEXdDO2ut3YA:10 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-ORIG-GUID: 6t63fY6GMGZwHKhP_LsNvOZcovC_IXpU X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzA0MDA2MCBTYWx0ZWRfX1gvUSirzGHmf Auxa9otYmTnpuGdBsmliXV4IQaQmQjZ6YR6zsyWCuk02knDmE9AkvuzweUGW3gHtDGUKcgBVrVB Rz85nlFXahjl7nVX8fji/b5/CEm4Db4ezDdqKbZz+GS+K5LnkMdZw3d5nDjhA0Uou0ND2+dSwgs VDB4hBL+Y6g5FQa20GAFSp6dU4w6QqRGbRM0MZ9XXI5RCC5JeL7Afou/K/9YPUOiiG2bQoqUlNv 8DrclUCU4DURi+i+q+h0L4TvX89eR8Wvl4XhGH5QCO/77TD33clp4AxSCi8MmELA6zSv5S4hnh6 IqtQgBDTb14WQEE6xQJ98hJsLntAOE/fEgI83HDuSzBIDQVDqNSgp9uRyo5vrQjSWbngAiOhz50 Tze1BK8D4QliOhV8rrqXBMtNkmHipaS4ppS4KNV4C4xqqwSCU8q0NNAhr3x7BUMySQpX1FRT X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-04_03,2025-07-02_04,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 impostorscore=0 priorityscore=1501 mlxlogscore=999 adultscore=0 malwarescore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 phishscore=0 bulkscore=0 suspectscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507040060 Add platform-specific capabilities for the encoder video device and initialize the corresponding controls in the control handler. This enables proper configuration and handling of encoder-specific features based on platform requirements. Signed-off-by: Dikshita Agarwal Tested-by: Vikash Garodia # X1E80100 --- drivers/media/platform/qcom/iris/iris_core.h | 7 +- drivers/media/platform/qcom/iris/iris_ctrls.c | 175 +++++++++- .../platform/qcom/iris/iris_hfi_gen1_defines.h | 8 + .../platform/qcom/iris/iris_hfi_gen2_defines.h | 9 + .../platform/qcom/iris/iris_platform_common.h | 42 ++- .../media/platform/qcom/iris/iris_platform_gen2.c | 367 +++++++++++++++++= +++- .../platform/qcom/iris/iris_platform_qcs8300.h | 350 +++++++++++++++++= ++- .../platform/qcom/iris/iris_platform_sm8250.c | 195 ++++++++++- drivers/media/platform/qcom/iris/iris_vdec.c | 2 +- drivers/media/platform/qcom/iris/iris_venc.c | 7 +- 10 files changed, 1132 insertions(+), 30 deletions(-) diff --git a/drivers/media/platform/qcom/iris/iris_core.h b/drivers/media/p= latform/qcom/iris/iris_core.h index 827aee8dcec3ee17af5a90f5594b9315f663c0b3..fb194c967ad4f9b5e00cd74f0d4= 1e0b827ef14db 100644 --- a/drivers/media/platform/qcom/iris/iris_core.h +++ b/drivers/media/platform/qcom/iris/iris_core.h @@ -71,7 +71,8 @@ enum domain_type { * @intr_status: interrupt status * @sys_error_handler: a delayed work for handling system fatal error * @instances: a list_head of all instances - * @inst_fw_caps: an array of supported instance capabilities + * @inst_fw_caps_dec: an array of supported instance capabilities by decod= er + * @inst_fw_caps_enc: an array of supported instance capabilities by encod= er */ =20 struct iris_core { @@ -113,7 +114,9 @@ struct iris_core { u32 intr_status; struct delayed_work sys_error_handler; struct list_head instances; - struct platform_inst_fw_cap inst_fw_caps[INST_FW_CAP_MAX]; + /* encoder and decoder have overlapping caps, so two different arrays are= required */ + struct platform_inst_fw_cap inst_fw_caps_dec[INST_FW_CAP_MAX]; + struct platform_inst_fw_cap inst_fw_caps_enc[INST_FW_CAP_MAX]; }; =20 int iris_core_init(struct iris_core *core); diff --git a/drivers/media/platform/qcom/iris/iris_ctrls.c b/drivers/media/= platform/qcom/iris/iris_ctrls.c index 9136b723c0f2a3d5833af32ae2735ccdb244f60f..797386cb96ab1d24be6cc1819e2= f9202ab4cc224 100644 --- a/drivers/media/platform/qcom/iris/iris_ctrls.c +++ b/drivers/media/platform/qcom/iris/iris_ctrls.c @@ -31,6 +31,68 @@ static enum platform_inst_fw_cap_type iris_get_cap_id(u3= 2 id) return LEVEL_VP9; case V4L2_CID_MPEG_VIDEO_HEVC_TIER: return TIER; + case V4L2_CID_MPEG_VIDEO_HEADER_MODE: + return HEADER_MODE; + case V4L2_CID_MPEG_VIDEO_PREPEND_SPSPPS_TO_IDR: + return PREPEND_SPSPPS_TO_IDR; + case V4L2_CID_MPEG_VIDEO_BITRATE: + return BITRATE; + case V4L2_CID_MPEG_VIDEO_BITRATE_PEAK: + return BITRATE_PEAK; + case V4L2_CID_MPEG_VIDEO_BITRATE_MODE: + return BITRATE_MODE; + case V4L2_CID_MPEG_VIDEO_FRAME_SKIP_MODE: + return FRAME_SKIP_MODE; + case V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE: + return FRAME_RC_ENABLE; + case V4L2_CID_MPEG_VIDEO_GOP_SIZE: + return GOP_SIZE; + case V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE: + return ENTROPY_MODE; + case V4L2_CID_MPEG_VIDEO_H264_MIN_QP: + return MIN_FRAME_QP_H264; + case V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP: + return MIN_FRAME_QP_HEVC; + case V4L2_CID_MPEG_VIDEO_H264_MAX_QP: + return MAX_FRAME_QP_H264; + case V4L2_CID_MPEG_VIDEO_HEVC_MAX_QP: + return MAX_FRAME_QP_HEVC; + case V4L2_CID_MPEG_VIDEO_H264_I_FRAME_MIN_QP: + return I_FRAME_MIN_QP_H264; + case V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_MIN_QP: + return I_FRAME_MIN_QP_HEVC; + case V4L2_CID_MPEG_VIDEO_H264_P_FRAME_MIN_QP: + return P_FRAME_MIN_QP_H264; + case V4L2_CID_MPEG_VIDEO_HEVC_P_FRAME_MIN_QP: + return P_FRAME_MIN_QP_HEVC; + case V4L2_CID_MPEG_VIDEO_H264_B_FRAME_MIN_QP: + return B_FRAME_MIN_QP_H264; + case V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_MIN_QP: + return B_FRAME_MIN_QP_HEVC; + case V4L2_CID_MPEG_VIDEO_H264_I_FRAME_MAX_QP: + return I_FRAME_MAX_QP_H264; + case V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_MAX_QP: + return I_FRAME_MAX_QP_HEVC; + case V4L2_CID_MPEG_VIDEO_H264_P_FRAME_MAX_QP: + return P_FRAME_MAX_QP_H264; + case V4L2_CID_MPEG_VIDEO_HEVC_P_FRAME_MAX_QP: + return P_FRAME_MAX_QP_HEVC; + case V4L2_CID_MPEG_VIDEO_H264_B_FRAME_MAX_QP: + return B_FRAME_MAX_QP_H264; + case V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_MAX_QP: + return B_FRAME_MAX_QP_HEVC; + case V4L2_CID_MPEG_VIDEO_H264_I_FRAME_QP: + return I_FRAME_QP_H264; + case V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_QP: + return I_FRAME_QP_HEVC; + case V4L2_CID_MPEG_VIDEO_H264_P_FRAME_QP: + return P_FRAME_QP_H264; + case V4L2_CID_MPEG_VIDEO_HEVC_P_FRAME_QP: + return P_FRAME_QP_HEVC; + case V4L2_CID_MPEG_VIDEO_H264_B_FRAME_QP: + return B_FRAME_QP_H264; + case V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_QP: + return B_FRAME_QP_HEVC; default: return INST_FW_CAP_MAX; } @@ -56,6 +118,68 @@ static u32 iris_get_v4l2_id(enum platform_inst_fw_cap_t= ype cap_id) return V4L2_CID_MPEG_VIDEO_VP9_LEVEL; case TIER: return V4L2_CID_MPEG_VIDEO_HEVC_TIER; + case HEADER_MODE: + return V4L2_CID_MPEG_VIDEO_HEADER_MODE; + case PREPEND_SPSPPS_TO_IDR: + return V4L2_CID_MPEG_VIDEO_PREPEND_SPSPPS_TO_IDR; + case BITRATE: + return V4L2_CID_MPEG_VIDEO_BITRATE; + case BITRATE_PEAK: + return V4L2_CID_MPEG_VIDEO_BITRATE_PEAK; + case BITRATE_MODE: + return V4L2_CID_MPEG_VIDEO_BITRATE_MODE; + case FRAME_SKIP_MODE: + return V4L2_CID_MPEG_VIDEO_FRAME_SKIP_MODE; + case FRAME_RC_ENABLE: + return V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE; + case GOP_SIZE: + return V4L2_CID_MPEG_VIDEO_GOP_SIZE; + case ENTROPY_MODE: + return V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE; + case MIN_FRAME_QP_H264: + return V4L2_CID_MPEG_VIDEO_H264_MIN_QP; + case MIN_FRAME_QP_HEVC: + return V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP; + case MAX_FRAME_QP_H264: + return V4L2_CID_MPEG_VIDEO_H264_MAX_QP; + case MAX_FRAME_QP_HEVC: + return V4L2_CID_MPEG_VIDEO_HEVC_MAX_QP; + case I_FRAME_MIN_QP_H264: + return V4L2_CID_MPEG_VIDEO_H264_I_FRAME_MIN_QP; + case I_FRAME_MIN_QP_HEVC: + return V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_MIN_QP; + case P_FRAME_MIN_QP_H264: + return V4L2_CID_MPEG_VIDEO_H264_P_FRAME_MIN_QP; + case P_FRAME_MIN_QP_HEVC: + return V4L2_CID_MPEG_VIDEO_HEVC_P_FRAME_MIN_QP; + case B_FRAME_MIN_QP_H264: + return V4L2_CID_MPEG_VIDEO_H264_B_FRAME_MIN_QP; + case B_FRAME_MIN_QP_HEVC: + return V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_MIN_QP; + case I_FRAME_MAX_QP_H264: + return V4L2_CID_MPEG_VIDEO_H264_I_FRAME_MAX_QP; + case I_FRAME_MAX_QP_HEVC: + return V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_MAX_QP; + case P_FRAME_MAX_QP_H264: + return V4L2_CID_MPEG_VIDEO_H264_P_FRAME_MAX_QP; + case P_FRAME_MAX_QP_HEVC: + return V4L2_CID_MPEG_VIDEO_HEVC_P_FRAME_MAX_QP; + case B_FRAME_MAX_QP_H264: + return V4L2_CID_MPEG_VIDEO_H264_B_FRAME_MAX_QP; + case B_FRAME_MAX_QP_HEVC: + return V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_MAX_QP; + case I_FRAME_QP_H264: + return V4L2_CID_MPEG_VIDEO_H264_I_FRAME_QP; + case I_FRAME_QP_HEVC: + return V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_QP; + case P_FRAME_QP_H264: + return V4L2_CID_MPEG_VIDEO_H264_P_FRAME_QP; + case P_FRAME_QP_HEVC: + return V4L2_CID_MPEG_VIDEO_HEVC_P_FRAME_QP; + case B_FRAME_QP_H264: + return V4L2_CID_MPEG_VIDEO_H264_B_FRAME_QP; + case B_FRAME_QP_HEVC: + return V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_QP; default: return 0; } @@ -101,7 +225,10 @@ int iris_ctrls_init(struct iris_inst *inst) num_ctrls++; } =20 - /* Adding 1 to num_ctrls to include V4L2_CID_MIN_BUFFERS_FOR_CAPTURE */ + /* Adding 1 to num_ctrls to include + * V4L2_CID_MIN_BUFFERS_FOR_CAPTURE for decoder and + * V4L2_CID_MIN_BUFFERS_FOR_OUTPUT for encoder + */ =20 ret =3D v4l2_ctrl_handler_init(&inst->ctrl_handler, num_ctrls + 1); if (ret) @@ -143,8 +270,13 @@ int iris_ctrls_init(struct iris_inst *inst) ctrl_idx++; } =20 - v4l2_ctrl_new_std(&inst->ctrl_handler, NULL, - V4L2_CID_MIN_BUFFERS_FOR_CAPTURE, 1, 32, 1, 4); + if (inst->domain =3D=3D DECODER) { + v4l2_ctrl_new_std(&inst->ctrl_handler, NULL, + V4L2_CID_MIN_BUFFERS_FOR_CAPTURE, 1, 32, 1, 4); + } else { + v4l2_ctrl_new_std(&inst->ctrl_handler, NULL, + V4L2_CID_MIN_BUFFERS_FOR_OUTPUT, 1, 32, 1, 4); + } =20 ret =3D inst->ctrl_handler.error; if (ret) @@ -162,22 +294,39 @@ void iris_session_init_caps(struct iris_core *core) struct platform_inst_fw_cap *caps; u32 i, num_cap, cap_id; =20 - caps =3D core->iris_platform_data->inst_fw_caps; - num_cap =3D core->iris_platform_data->inst_fw_caps_size; + caps =3D core->iris_platform_data->inst_fw_caps_dec; + num_cap =3D core->iris_platform_data->inst_fw_caps_dec_size; + + for (i =3D 0; i < num_cap; i++) { + cap_id =3D caps[i].cap_id; + if (!iris_valid_cap_id(cap_id)) + continue; + + core->inst_fw_caps_dec[cap_id].cap_id =3D caps[i].cap_id; + core->inst_fw_caps_dec[cap_id].min =3D caps[i].min; + core->inst_fw_caps_dec[cap_id].max =3D caps[i].max; + core->inst_fw_caps_dec[cap_id].step_or_mask =3D caps[i].step_or_mask; + core->inst_fw_caps_dec[cap_id].value =3D caps[i].value; + core->inst_fw_caps_dec[cap_id].flags =3D caps[i].flags; + core->inst_fw_caps_dec[cap_id].hfi_id =3D caps[i].hfi_id; + core->inst_fw_caps_dec[cap_id].set =3D caps[i].set; + } + + caps =3D core->iris_platform_data->inst_fw_caps_enc; + num_cap =3D core->iris_platform_data->inst_fw_caps_enc_size; =20 for (i =3D 0; i < num_cap; i++) { cap_id =3D caps[i].cap_id; if (!iris_valid_cap_id(cap_id)) continue; =20 - core->inst_fw_caps[cap_id].cap_id =3D caps[i].cap_id; - core->inst_fw_caps[cap_id].min =3D caps[i].min; - core->inst_fw_caps[cap_id].max =3D caps[i].max; - core->inst_fw_caps[cap_id].step_or_mask =3D caps[i].step_or_mask; - core->inst_fw_caps[cap_id].value =3D caps[i].value; - core->inst_fw_caps[cap_id].flags =3D caps[i].flags; - core->inst_fw_caps[cap_id].hfi_id =3D caps[i].hfi_id; - core->inst_fw_caps[cap_id].set =3D caps[i].set; + core->inst_fw_caps_enc[cap_id].cap_id =3D caps[i].cap_id; + core->inst_fw_caps_enc[cap_id].min =3D caps[i].min; + core->inst_fw_caps_enc[cap_id].max =3D caps[i].max; + core->inst_fw_caps_enc[cap_id].step_or_mask =3D caps[i].step_or_mask; + core->inst_fw_caps_enc[cap_id].value =3D caps[i].value; + core->inst_fw_caps_enc[cap_id].flags =3D caps[i].flags; + core->inst_fw_caps_enc[cap_id].hfi_id =3D caps[i].hfi_id; } } =20 diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen1_defines.h b/dri= vers/media/platform/qcom/iris/iris_hfi_gen1_defines.h index 5b7c641b727a16c3aa7196a6d49786133653279f..f6e2db401daeee12106a07af621= 79ce0d1504c5c 100644 --- a/drivers/media/platform/qcom/iris/iris_hfi_gen1_defines.h +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen1_defines.h @@ -121,6 +121,14 @@ #define HFI_UNUSED_PICT 0x10000000 #define HFI_BUFFERFLAG_DATACORRUPT 0x00000008 #define HFI_BUFFERFLAG_DROP_FRAME 0x20000000 +#define HFI_PROPERTY_PARAM_VENC_H264_ENTROPY_CONTROL 0x2005002 +#define HFI_PROPERTY_PARAM_VENC_H264_DEBLOCK_CONTROL 0x2005003 +#define HFI_PROPERTY_PARAM_VENC_RATE_CONTROL 0x2005004 +#define HFI_PROPERTY_PARAM_VENC_SESSION_QP_RANGE_V2 0x2005009 +#define HFI_PROPERTY_PARAM_VENC_MAX_NUM_B_FRAMES 0x2005020 +#define HFI_PROPERTY_CONFIG_VENC_TARGET_BITRATE 0x2006001 +#define HFI_PROPERTY_CONFIG_VENC_MAX_BITRATE 0x2006007 +#define HFI_PROPERTY_CONFIG_VENC_SYNC_FRAME_SEQUENCE_HEADER 0x2006008 =20 struct hfi_pkt_hdr { u32 size; diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen2_defines.h b/dri= vers/media/platform/qcom/iris/iris_hfi_gen2_defines.h index 5f13dc11bea532600cc9b15db57e8981a1f3eb93..fb6724d7f95ff8858aa9ba093fe= fb642e89de279 100644 --- a/drivers/media/platform/qcom/iris/iris_hfi_gen2_defines.h +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen2_defines.h @@ -55,12 +55,21 @@ #define HFI_PROP_BUFFER_HOST_MAX_COUNT 0x03000123 #define HFI_PROP_BUFFER_FW_MIN_OUTPUT_COUNT 0x03000124 #define HFI_PROP_PIC_ORDER_CNT_TYPE 0x03000128 +#define HFI_PROP_RATE_CONTROL 0x0300012a +#define HFI_PROP_QP_PACKED 0x0300012e +#define HFI_PROP_MIN_QP_PACKED 0x0300012f +#define HFI_PROP_MAX_QP_PACKED 0x03000130 +#define HFI_PROP_TOTAL_BITRATE 0x0300013b +#define HFI_PROP_MAX_GOP_FRAMES 0x03000146 +#define HFI_PROP_MAX_B_FRAMES 0x03000147 #define HFI_PROP_QUALITY_MODE 0x03000148 +#define HFI_PROP_SEQ_HEADER_MODE 0x03000149 #define HFI_PROP_SIGNAL_COLOR_INFO 0x03000155 #define HFI_PROP_PICTURE_TYPE 0x03000162 #define HFI_PROP_DEC_DEFAULT_HEADER 0x03000168 #define HFI_PROP_DEC_START_FROM_RAP_FRAME 0x03000169 #define HFI_PROP_NO_OUTPUT 0x0300016a +#define HFI_PROP_TOTAL_PEAK_BITRATE 0x0300017C #define HFI_PROP_COMV_BUFFER_COUNT 0x03000193 #define HFI_PROP_END 0x03FFFFFF =20 diff --git a/drivers/media/platform/qcom/iris/iris_platform_common.h b/driv= ers/media/platform/qcom/iris/iris_platform_common.h index d0b84c93aef409b51a767ba11f91c6ce2533f27f..49adb0a52bbf19849d0cc411790= 63b667a0ccb2f 100644 --- a/drivers/media/platform/qcom/iris/iris_platform_common.h +++ b/drivers/media/platform/qcom/iris/iris_platform_common.h @@ -23,6 +23,11 @@ struct iris_inst; #define DEFAULT_FPS 30 #define MAXIMUM_FPS 480 #define NUM_MBS_8K ((8192 * 4352) / 256) +#define MIN_QP_8BIT 1 +#define MAX_QP 51 +#define MAX_QP_HEVC 63 +#define DEFAULT_QP 20 +#define BITRATE_DEFAULT 20000000 =20 enum stage_type { STAGE_1 =3D 1, @@ -98,6 +103,37 @@ enum platform_inst_fw_cap_type { BIT_DEPTH, RAP_FRAME, TIER, + HEADER_MODE, + PREPEND_SPSPPS_TO_IDR, + BITRATE, + BITRATE_PEAK, + BITRATE_MODE, + FRAME_SKIP_MODE, + FRAME_RC_ENABLE, + GOP_SIZE, + ENTROPY_MODE, + MIN_FRAME_QP_H264, + MIN_FRAME_QP_HEVC, + MAX_FRAME_QP_H264, + MAX_FRAME_QP_HEVC, + I_FRAME_MIN_QP_H264, + I_FRAME_MIN_QP_HEVC, + P_FRAME_MIN_QP_H264, + P_FRAME_MIN_QP_HEVC, + B_FRAME_MIN_QP_H264, + B_FRAME_MIN_QP_HEVC, + I_FRAME_MAX_QP_H264, + I_FRAME_MAX_QP_HEVC, + P_FRAME_MAX_QP_H264, + P_FRAME_MAX_QP_HEVC, + B_FRAME_MAX_QP_H264, + B_FRAME_MAX_QP_HEVC, + I_FRAME_QP_H264, + I_FRAME_QP_HEVC, + P_FRAME_QP_H264, + P_FRAME_QP_HEVC, + B_FRAME_QP_H264, + B_FRAME_QP_HEVC, INST_FW_CAP_MAX, }; =20 @@ -172,8 +208,10 @@ struct iris_platform_data { const char *fwname; u32 pas_id; struct platform_inst_caps *inst_caps; - struct platform_inst_fw_cap *inst_fw_caps; - u32 inst_fw_caps_size; + struct platform_inst_fw_cap *inst_fw_caps_dec; + u32 inst_fw_caps_dec_size; + struct platform_inst_fw_cap *inst_fw_caps_enc; + u32 inst_fw_caps_enc_size; struct tz_cp_config *tz_cp_config_data; u32 core_arch; u32 hw_response_timeout; diff --git a/drivers/media/platform/qcom/iris/iris_platform_gen2.c b/driver= s/media/platform/qcom/iris/iris_platform_gen2.c index e047fb75a99a6372dac4ad029baea16034cac633..04e76445dd9141285a6e48be76b= df1bdb51f0cee 100644 --- a/drivers/media/platform/qcom/iris/iris_platform_gen2.c +++ b/drivers/media/platform/qcom/iris/iris_platform_gen2.c @@ -14,8 +14,9 @@ #include "iris_platform_sm8650.h" =20 #define VIDEO_ARCH_LX 1 +#define BITRATE_MAX 245000000 =20 -static struct platform_inst_fw_cap inst_fw_cap_sm8550[] =3D { +static struct platform_inst_fw_cap inst_fw_cap_sm8550_dec[] =3D { { .cap_id =3D PROFILE_H264, .min =3D V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE, @@ -199,6 +200,352 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8550= [] =3D { }, }; =20 +static struct platform_inst_fw_cap inst_fw_cap_sm8550_enc[] =3D { + { + .cap_id =3D PROFILE_H264, + .min =3D V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE, + .max =3D V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_HIGH, + .step_or_mask =3D BIT(V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE) | + BIT(V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_HIGH) | + BIT(V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_BASELINE) | + BIT(V4L2_MPEG_VIDEO_H264_PROFILE_MAIN) | + BIT(V4L2_MPEG_VIDEO_H264_PROFILE_HIGH), + .value =3D V4L2_MPEG_VIDEO_H264_PROFILE_HIGH, + .hfi_id =3D HFI_PROP_PROFILE, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + }, + { + .cap_id =3D PROFILE_HEVC, + .min =3D V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN, + .max =3D V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10, + .step_or_mask =3D BIT(V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN) | + BIT(V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_STILL_PICTURE) | + BIT(V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10), + .value =3D V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN, + .hfi_id =3D HFI_PROP_PROFILE, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + }, + { + .cap_id =3D LEVEL_H264, + .min =3D V4L2_MPEG_VIDEO_H264_LEVEL_1_0, + .max =3D V4L2_MPEG_VIDEO_H264_LEVEL_6_0, + .step_or_mask =3D BIT(V4L2_MPEG_VIDEO_H264_LEVEL_1_0) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_1B) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_1_1) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_1_2) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_1_3) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_2_0) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_2_1) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_2_2) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_3_0) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_3_1) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_3_2) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_4_0) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_4_1) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_4_2) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_5_0) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_5_1) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_5_2) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_6_0), + .value =3D V4L2_MPEG_VIDEO_H264_LEVEL_5_0, + .hfi_id =3D HFI_PROP_LEVEL, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + }, + { + .cap_id =3D LEVEL_HEVC, + .min =3D V4L2_MPEG_VIDEO_HEVC_LEVEL_1, + .max =3D V4L2_MPEG_VIDEO_HEVC_LEVEL_6_2, + .step_or_mask =3D BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_1) | + BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_2) | + BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_2_1) | + BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_3) | + BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_3_1) | + BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_4) | + BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_4_1) | + BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_5) | + BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_5_1) | + BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_5_2) | + BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_6) | + BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_6_1) | + BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_6_2), + .value =3D V4L2_MPEG_VIDEO_HEVC_LEVEL_5, + .hfi_id =3D HFI_PROP_LEVEL, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + }, + { + .cap_id =3D STAGE, + .min =3D STAGE_1, + .max =3D STAGE_2, + .step_or_mask =3D 1, + .value =3D STAGE_2, + .hfi_id =3D HFI_PROP_STAGE, + }, + { + .cap_id =3D HEADER_MODE, + .min =3D V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE, + .max =3D V4L2_MPEG_VIDEO_HEADER_MODE_JOINED_WITH_1ST_FRAME, + .step_or_mask =3D BIT(V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE) | + BIT(V4L2_MPEG_VIDEO_HEADER_MODE_JOINED_WITH_1ST_FRAME), + .value =3D V4L2_MPEG_VIDEO_HEADER_MODE_JOINED_WITH_1ST_FRAME, + .hfi_id =3D HFI_PROP_SEQ_HEADER_MODE, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + }, + { + .cap_id =3D PREPEND_SPSPPS_TO_IDR, + .min =3D 0, + .max =3D 1, + .step_or_mask =3D 1, + .value =3D 0, + }, + { + .cap_id =3D BITRATE, + .min =3D 1, + .max =3D BITRATE_MAX, + .step_or_mask =3D 1, + .value =3D BITRATE_DEFAULT, + .hfi_id =3D HFI_PROP_TOTAL_BITRATE, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | + CAP_FLAG_DYNAMIC_ALLOWED, + }, + { + .cap_id =3D BITRATE_PEAK, + .min =3D 1, + .max =3D BITRATE_MAX, + .step_or_mask =3D 1, + .value =3D BITRATE_DEFAULT, + .hfi_id =3D HFI_PROP_TOTAL_PEAK_BITRATE, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | + CAP_FLAG_DYNAMIC_ALLOWED, + }, + { + .cap_id =3D BITRATE_MODE, + .min =3D V4L2_MPEG_VIDEO_BITRATE_MODE_VBR, + .max =3D V4L2_MPEG_VIDEO_BITRATE_MODE_CBR, + .step_or_mask =3D BIT(V4L2_MPEG_VIDEO_BITRATE_MODE_VBR) | + BIT(V4L2_MPEG_VIDEO_BITRATE_MODE_CBR), + .value =3D V4L2_MPEG_VIDEO_BITRATE_MODE_VBR, + .hfi_id =3D HFI_PROP_RATE_CONTROL, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + }, + { + .cap_id =3D FRAME_SKIP_MODE, + .min =3D V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_DISABLED, + .max =3D V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT, + .step_or_mask =3D BIT(V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_DISABLED) | + BIT(V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_LEVEL_LIMIT) | + BIT(V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT), + .value =3D V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_DISABLED, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + }, + { + .cap_id =3D FRAME_RC_ENABLE, + .min =3D 0, + .max =3D 1, + .step_or_mask =3D 1, + .value =3D 1, + }, + { + .cap_id =3D GOP_SIZE, + .min =3D 0, + .max =3D INT_MAX, + .step_or_mask =3D 1, + .value =3D 2 * DEFAULT_FPS - 1, + .hfi_id =3D HFI_PROP_MAX_GOP_FRAMES, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | + CAP_FLAG_DYNAMIC_ALLOWED, + }, + { + .cap_id =3D ENTROPY_MODE, + .min =3D V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CAVLC, + .max =3D V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CABAC, + .step_or_mask =3D BIT(V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CAVLC) | + BIT(V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CABAC), + .value =3D V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CABAC, + .hfi_id =3D HFI_PROP_CABAC_SESSION, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + }, + { + .cap_id =3D MIN_FRAME_QP_H264, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D MIN_QP_8BIT, + .hfi_id =3D HFI_PROP_MIN_QP_PACKED, + .flags =3D CAP_FLAG_OUTPUT_PORT, + }, + { + .cap_id =3D MIN_FRAME_QP_HEVC, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D MIN_QP_8BIT, + .hfi_id =3D HFI_PROP_MIN_QP_PACKED, + .flags =3D CAP_FLAG_OUTPUT_PORT, + }, + { + .cap_id =3D MAX_FRAME_QP_H264, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D MIN_QP_8BIT, + .hfi_id =3D HFI_PROP_MAX_QP_PACKED, + .flags =3D CAP_FLAG_OUTPUT_PORT, + }, + { + .cap_id =3D MAX_FRAME_QP_HEVC, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D MIN_QP_8BIT, + .hfi_id =3D HFI_PROP_MAX_QP_PACKED, + .flags =3D CAP_FLAG_OUTPUT_PORT, + }, + { + .cap_id =3D I_FRAME_MIN_QP_H264, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D MIN_QP_8BIT, + }, + { + .cap_id =3D I_FRAME_MIN_QP_HEVC, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D MIN_QP_8BIT, + }, + { + .cap_id =3D P_FRAME_MIN_QP_H264, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D MIN_QP_8BIT, + }, + { + .cap_id =3D P_FRAME_MIN_QP_HEVC, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D MIN_QP_8BIT, + }, + { + .cap_id =3D B_FRAME_MIN_QP_H264, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D MIN_QP_8BIT, + }, + { + .cap_id =3D B_FRAME_MIN_QP_HEVC, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D MIN_QP_8BIT, + }, + { + .cap_id =3D I_FRAME_MAX_QP_H264, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D MIN_QP_8BIT, + }, + { + .cap_id =3D I_FRAME_MAX_QP_HEVC, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D MIN_QP_8BIT, + }, + { + .cap_id =3D P_FRAME_MAX_QP_H264, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D MIN_QP_8BIT, + }, + { + .cap_id =3D P_FRAME_MAX_QP_HEVC, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D MIN_QP_8BIT, + }, + { + .cap_id =3D B_FRAME_MAX_QP_H264, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D MIN_QP_8BIT, + }, + { + .cap_id =3D B_FRAME_MAX_QP_HEVC, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D MIN_QP_8BIT, + }, + { + .cap_id =3D I_FRAME_QP_H264, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D DEFAULT_QP, + .hfi_id =3D HFI_PROP_QP_PACKED, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | + CAP_FLAG_DYNAMIC_ALLOWED, + }, + { + .cap_id =3D I_FRAME_QP_HEVC, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D DEFAULT_QP, + .hfi_id =3D HFI_PROP_QP_PACKED, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | + CAP_FLAG_DYNAMIC_ALLOWED, + }, + { + .cap_id =3D P_FRAME_QP_H264, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D DEFAULT_QP, + .hfi_id =3D HFI_PROP_QP_PACKED, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | + CAP_FLAG_DYNAMIC_ALLOWED, + }, + { + .cap_id =3D P_FRAME_QP_HEVC, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D DEFAULT_QP, + .hfi_id =3D HFI_PROP_QP_PACKED, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | + CAP_FLAG_DYNAMIC_ALLOWED, + }, + { + .cap_id =3D B_FRAME_QP_H264, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D DEFAULT_QP, + .hfi_id =3D HFI_PROP_QP_PACKED, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | + CAP_FLAG_DYNAMIC_ALLOWED, + }, + { + .cap_id =3D B_FRAME_QP_HEVC, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D DEFAULT_QP, + .hfi_id =3D HFI_PROP_QP_PACKED, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | + CAP_FLAG_DYNAMIC_ALLOWED, + }, +}; + static struct platform_inst_caps platform_inst_cap_sm8550 =3D { .min_frame_width =3D 96, .max_frame_width =3D 8192, @@ -347,8 +694,10 @@ struct iris_platform_data sm8550_data =3D { .fwname =3D "qcom/vpu/vpu30_p4.mbn", .pas_id =3D IRIS_PAS_ID, .inst_caps =3D &platform_inst_cap_sm8550, - .inst_fw_caps =3D inst_fw_cap_sm8550, - .inst_fw_caps_size =3D ARRAY_SIZE(inst_fw_cap_sm8550), + .inst_fw_caps_dec =3D inst_fw_cap_sm8550_dec, + .inst_fw_caps_dec_size =3D ARRAY_SIZE(inst_fw_cap_sm8550_dec), + .inst_fw_caps_enc =3D inst_fw_cap_sm8550_enc, + .inst_fw_caps_enc_size =3D ARRAY_SIZE(inst_fw_cap_sm8550_enc), .tz_cp_config_data =3D &tz_cp_config_sm8550, .core_arch =3D VIDEO_ARCH_LX, .hw_response_timeout =3D HW_RESPONSE_TIMEOUT_VALUE, @@ -423,8 +772,10 @@ struct iris_platform_data sm8650_data =3D { .fwname =3D "qcom/vpu/vpu33_p4.mbn", .pas_id =3D IRIS_PAS_ID, .inst_caps =3D &platform_inst_cap_sm8550, - .inst_fw_caps =3D inst_fw_cap_sm8550, - .inst_fw_caps_size =3D ARRAY_SIZE(inst_fw_cap_sm8550), + .inst_fw_caps_dec =3D inst_fw_cap_sm8550_dec, + .inst_fw_caps_dec_size =3D ARRAY_SIZE(inst_fw_cap_sm8550_dec), + .inst_fw_caps_enc =3D inst_fw_cap_sm8550_enc, + .inst_fw_caps_enc_size =3D ARRAY_SIZE(inst_fw_cap_sm8550_enc), .tz_cp_config_data =3D &tz_cp_config_sm8550, .core_arch =3D VIDEO_ARCH_LX, .hw_response_timeout =3D HW_RESPONSE_TIMEOUT_VALUE, @@ -495,8 +846,10 @@ struct iris_platform_data qcs8300_data =3D { .fwname =3D "qcom/vpu/vpu30_p4_s6.mbn", .pas_id =3D IRIS_PAS_ID, .inst_caps =3D &platform_inst_cap_qcs8300, - .inst_fw_caps =3D inst_fw_cap_qcs8300, - .inst_fw_caps_size =3D ARRAY_SIZE(inst_fw_cap_qcs8300), + .inst_fw_caps_dec =3D inst_fw_cap_qcs8300_dec, + .inst_fw_caps_dec_size =3D ARRAY_SIZE(inst_fw_cap_qcs8300_dec), + .inst_fw_caps_enc =3D inst_fw_cap_qcs8300_enc, + .inst_fw_caps_enc_size =3D ARRAY_SIZE(inst_fw_cap_qcs8300_enc), .tz_cp_config_data =3D &tz_cp_config_sm8550, .core_arch =3D VIDEO_ARCH_LX, .hw_response_timeout =3D HW_RESPONSE_TIMEOUT_VALUE, diff --git a/drivers/media/platform/qcom/iris/iris_platform_qcs8300.h b/dri= vers/media/platform/qcom/iris/iris_platform_qcs8300.h index 22e485b0b2ae8f110d2f3b817e202d1aa7d227fd..33764f05fe1a75014fb69051ac1= fc0eeb97628ef 100644 --- a/drivers/media/platform/qcom/iris/iris_platform_qcs8300.h +++ b/drivers/media/platform/qcom/iris/iris_platform_qcs8300.h @@ -3,7 +3,9 @@ * Copyright (c) 2022-2025 Qualcomm Innovation Center, Inc. All rights res= erved. */ =20 -static struct platform_inst_fw_cap inst_fw_cap_qcs8300[] =3D { +#define BITRATE_MAX 245000000 + +static struct platform_inst_fw_cap inst_fw_cap_qcs8300_dec[] =3D { { .cap_id =3D PROFILE_H264, .min =3D V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE, @@ -187,6 +189,352 @@ static struct platform_inst_fw_cap inst_fw_cap_qcs830= 0[] =3D { }, }; =20 +static struct platform_inst_fw_cap inst_fw_cap_qcs8300_enc[] =3D { + { + .cap_id =3D PROFILE_H264, + .min =3D V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE, + .max =3D V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_HIGH, + .step_or_mask =3D BIT(V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE) | + BIT(V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_HIGH) | + BIT(V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_BASELINE) | + BIT(V4L2_MPEG_VIDEO_H264_PROFILE_MAIN) | + BIT(V4L2_MPEG_VIDEO_H264_PROFILE_HIGH), + .value =3D V4L2_MPEG_VIDEO_H264_PROFILE_HIGH, + .hfi_id =3D HFI_PROP_PROFILE, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + }, + { + .cap_id =3D PROFILE_HEVC, + .min =3D V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN, + .max =3D V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10, + .step_or_mask =3D BIT(V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN) | + BIT(V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_STILL_PICTURE) | + BIT(V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10), + .value =3D V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN, + .hfi_id =3D HFI_PROP_PROFILE, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + }, + { + .cap_id =3D LEVEL_H264, + .min =3D V4L2_MPEG_VIDEO_H264_LEVEL_1_0, + .max =3D V4L2_MPEG_VIDEO_H264_LEVEL_6_0, + .step_or_mask =3D BIT(V4L2_MPEG_VIDEO_H264_LEVEL_1_0) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_1B) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_1_1) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_1_2) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_1_3) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_2_0) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_2_1) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_2_2) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_3_0) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_3_1) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_3_2) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_4_0) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_4_1) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_4_2) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_5_0) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_5_1) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_5_2) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_6_0), + .value =3D V4L2_MPEG_VIDEO_H264_LEVEL_5_0, + .hfi_id =3D HFI_PROP_LEVEL, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + }, + { + .cap_id =3D LEVEL_HEVC, + .min =3D V4L2_MPEG_VIDEO_HEVC_LEVEL_1, + .max =3D V4L2_MPEG_VIDEO_HEVC_LEVEL_6_2, + .step_or_mask =3D BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_1) | + BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_2) | + BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_2_1) | + BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_3) | + BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_3_1) | + BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_4) | + BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_4_1) | + BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_5) | + BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_5_1) | + BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_5_2) | + BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_6) | + BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_6_1) | + BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_6_2), + .value =3D V4L2_MPEG_VIDEO_HEVC_LEVEL_5, + .hfi_id =3D HFI_PROP_LEVEL, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + }, + { + .cap_id =3D STAGE, + .min =3D STAGE_1, + .max =3D STAGE_2, + .step_or_mask =3D 1, + .value =3D STAGE_2, + .hfi_id =3D HFI_PROP_STAGE, + }, + { + .cap_id =3D HEADER_MODE, + .min =3D V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE, + .max =3D V4L2_MPEG_VIDEO_HEADER_MODE_JOINED_WITH_1ST_FRAME, + .step_or_mask =3D BIT(V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE) | + BIT(V4L2_MPEG_VIDEO_HEADER_MODE_JOINED_WITH_1ST_FRAME), + .value =3D V4L2_MPEG_VIDEO_HEADER_MODE_JOINED_WITH_1ST_FRAME, + .hfi_id =3D HFI_PROP_SEQ_HEADER_MODE, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + }, + { + .cap_id =3D PREPEND_SPSPPS_TO_IDR, + .min =3D 0, + .max =3D 1, + .step_or_mask =3D 1, + .value =3D 0, + }, + { + .cap_id =3D BITRATE, + .min =3D 1, + .max =3D BITRATE_MAX, + .step_or_mask =3D 1, + .value =3D BITRATE_DEFAULT, + .hfi_id =3D HFI_PROP_TOTAL_BITRATE, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | + CAP_FLAG_DYNAMIC_ALLOWED, + }, + { + .cap_id =3D BITRATE_PEAK, + .min =3D 1, + .max =3D BITRATE_MAX, + .step_or_mask =3D 1, + .value =3D BITRATE_DEFAULT, + .hfi_id =3D HFI_PROP_TOTAL_PEAK_BITRATE, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | + CAP_FLAG_DYNAMIC_ALLOWED, + }, + { + .cap_id =3D BITRATE_MODE, + .min =3D V4L2_MPEG_VIDEO_BITRATE_MODE_VBR, + .max =3D V4L2_MPEG_VIDEO_BITRATE_MODE_CBR, + .step_or_mask =3D BIT(V4L2_MPEG_VIDEO_BITRATE_MODE_VBR) | + BIT(V4L2_MPEG_VIDEO_BITRATE_MODE_CBR), + .value =3D V4L2_MPEG_VIDEO_BITRATE_MODE_VBR, + .hfi_id =3D HFI_PROP_RATE_CONTROL, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + }, + { + .cap_id =3D FRAME_SKIP_MODE, + .min =3D V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_DISABLED, + .max =3D V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT, + .step_or_mask =3D BIT(V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_DISABLED) | + BIT(V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_LEVEL_LIMIT) | + BIT(V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT), + .value =3D V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_DISABLED, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + }, + { + .cap_id =3D FRAME_RC_ENABLE, + .min =3D 0, + .max =3D 1, + .step_or_mask =3D 1, + .value =3D 1, + }, + { + .cap_id =3D GOP_SIZE, + .min =3D 0, + .max =3D INT_MAX, + .step_or_mask =3D 1, + .value =3D 2 * DEFAULT_FPS - 1, + .hfi_id =3D HFI_PROP_MAX_GOP_FRAMES, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | + CAP_FLAG_DYNAMIC_ALLOWED, + }, + { + .cap_id =3D ENTROPY_MODE, + .min =3D V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CAVLC, + .max =3D V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CABAC, + .step_or_mask =3D BIT(V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CAVLC) | + BIT(V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CABAC), + .value =3D V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CABAC, + .hfi_id =3D HFI_PROP_CABAC_SESSION, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + }, + { + .cap_id =3D MIN_FRAME_QP_H264, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D MIN_QP_8BIT, + .hfi_id =3D HFI_PROP_MIN_QP_PACKED, + .flags =3D CAP_FLAG_OUTPUT_PORT, + }, + { + .cap_id =3D MIN_FRAME_QP_HEVC, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D MIN_QP_8BIT, + .hfi_id =3D HFI_PROP_MIN_QP_PACKED, + .flags =3D CAP_FLAG_OUTPUT_PORT, + }, + { + .cap_id =3D MAX_FRAME_QP_H264, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D MIN_QP_8BIT, + .hfi_id =3D HFI_PROP_MAX_QP_PACKED, + .flags =3D CAP_FLAG_OUTPUT_PORT, + }, + { + .cap_id =3D MAX_FRAME_QP_HEVC, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D MIN_QP_8BIT, + .hfi_id =3D HFI_PROP_MAX_QP_PACKED, + .flags =3D CAP_FLAG_OUTPUT_PORT, + }, + { + .cap_id =3D I_FRAME_MIN_QP_H264, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D MIN_QP_8BIT, + }, + { + .cap_id =3D I_FRAME_MIN_QP_HEVC, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D MIN_QP_8BIT, + }, + { + .cap_id =3D P_FRAME_MIN_QP_H264, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D MIN_QP_8BIT, + }, + { + .cap_id =3D P_FRAME_MIN_QP_HEVC, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D MIN_QP_8BIT, + }, + { + .cap_id =3D B_FRAME_MIN_QP_H264, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D MIN_QP_8BIT, + }, + { + .cap_id =3D B_FRAME_MIN_QP_HEVC, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D MIN_QP_8BIT, + }, + { + .cap_id =3D I_FRAME_MAX_QP_H264, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D MIN_QP_8BIT, + }, + { + .cap_id =3D I_FRAME_MAX_QP_HEVC, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D MIN_QP_8BIT, + }, + { + .cap_id =3D P_FRAME_MAX_QP_H264, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D MIN_QP_8BIT, + }, + { + .cap_id =3D P_FRAME_MAX_QP_HEVC, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D MIN_QP_8BIT, + }, + { + .cap_id =3D B_FRAME_MAX_QP_H264, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D MIN_QP_8BIT, + }, + { + .cap_id =3D B_FRAME_MAX_QP_HEVC, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D MIN_QP_8BIT, + }, + { + .cap_id =3D I_FRAME_QP_H264, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D DEFAULT_QP, + .hfi_id =3D HFI_PROP_QP_PACKED, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | + CAP_FLAG_DYNAMIC_ALLOWED, + }, + { + .cap_id =3D I_FRAME_QP_HEVC, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D DEFAULT_QP, + .hfi_id =3D HFI_PROP_QP_PACKED, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | + CAP_FLAG_DYNAMIC_ALLOWED, + }, + { + .cap_id =3D P_FRAME_QP_H264, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D DEFAULT_QP, + .hfi_id =3D HFI_PROP_QP_PACKED, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | + CAP_FLAG_DYNAMIC_ALLOWED, + }, + { + .cap_id =3D P_FRAME_QP_HEVC, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D DEFAULT_QP, + .hfi_id =3D HFI_PROP_QP_PACKED, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | + CAP_FLAG_DYNAMIC_ALLOWED, + }, + { + .cap_id =3D B_FRAME_QP_H264, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D DEFAULT_QP, + .hfi_id =3D HFI_PROP_QP_PACKED, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | + CAP_FLAG_DYNAMIC_ALLOWED, + }, + { + .cap_id =3D B_FRAME_QP_HEVC, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D DEFAULT_QP, + .hfi_id =3D HFI_PROP_QP_PACKED, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | + CAP_FLAG_DYNAMIC_ALLOWED, + }, +}; + static struct platform_inst_caps platform_inst_cap_qcs8300 =3D { .min_frame_width =3D 96, .max_frame_width =3D 4096, diff --git a/drivers/media/platform/qcom/iris/iris_platform_sm8250.c b/driv= ers/media/platform/qcom/iris/iris_platform_sm8250.c index 5d59a5a3172a510b3a38f7c9c29dffd919fafce7..4f083eac261fff5642f15c4fc2f= 0f9f942818cac 100644 --- a/drivers/media/platform/qcom/iris/iris_platform_sm8250.c +++ b/drivers/media/platform/qcom/iris/iris_platform_sm8250.c @@ -11,7 +11,12 @@ #include "iris_hfi_gen1_defines.h" #include "iris_vpu_common.h" =20 -static struct platform_inst_fw_cap inst_fw_cap_sm8250[] =3D { +#define BITRATE_MIN 32000 +#define BITRATE_MAX 160000000 +#define BITRATE_PEAK_DEFAULT (BITRATE_DEFAULT * 2) +#define BITRATE_STEP 100 + +static struct platform_inst_fw_cap inst_fw_cap_sm8250_dec[] =3D { { .cap_id =3D PIPE, .min =3D PIPE_1, @@ -32,6 +37,188 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8250[]= =3D { }, }; =20 +static struct platform_inst_fw_cap inst_fw_cap_sm8250_enc[] =3D { + { + .cap_id =3D PROFILE_H264, + .min =3D V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE, + .max =3D V4L2_MPEG_VIDEO_H264_PROFILE_MULTIVIEW_HIGH, + .step_or_mask =3D BIT(V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE) | + BIT(V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_BASELINE) | + BIT(V4L2_MPEG_VIDEO_H264_PROFILE_MAIN) | + BIT(V4L2_MPEG_VIDEO_H264_PROFILE_HIGH) | + BIT(V4L2_MPEG_VIDEO_H264_PROFILE_STEREO_HIGH) | + BIT(V4L2_MPEG_VIDEO_H264_PROFILE_MULTIVIEW_HIGH), + .value =3D V4L2_MPEG_VIDEO_H264_PROFILE_HIGH, + .hfi_id =3D HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + }, + { + .cap_id =3D PROFILE_HEVC, + .min =3D V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN, + .max =3D V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10, + .step_or_mask =3D BIT(V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN) | + BIT(V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_STILL_PICTURE) | + BIT(V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10), + .value =3D V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN, + .hfi_id =3D HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + }, + { + .cap_id =3D LEVEL_H264, + .min =3D V4L2_MPEG_VIDEO_H264_LEVEL_1_0, + .max =3D V4L2_MPEG_VIDEO_H264_LEVEL_5_1, + .step_or_mask =3D BIT(V4L2_MPEG_VIDEO_H264_LEVEL_1_0) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_1B) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_1_1) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_1_2) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_1_3) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_2_0) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_2_1) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_2_2) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_3_0) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_3_1) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_3_2) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_4_0) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_4_1) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_4_2) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_5_0) | + BIT(V4L2_MPEG_VIDEO_H264_LEVEL_5_1), + .value =3D V4L2_MPEG_VIDEO_H264_LEVEL_1_0, + .hfi_id =3D HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + }, + { + .cap_id =3D LEVEL_HEVC, + .min =3D V4L2_MPEG_VIDEO_HEVC_LEVEL_1, + .max =3D V4L2_MPEG_VIDEO_HEVC_LEVEL_6_2, + .step_or_mask =3D BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_1) | + BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_2) | + BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_2_1) | + BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_3) | + BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_3_1) | + BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_4) | + BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_4_1) | + BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_5) | + BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_5_1) | + BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_5_2) | + BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_6) | + BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_6_1) | + BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_6_2), + .value =3D V4L2_MPEG_VIDEO_H264_LEVEL_1_0, + .hfi_id =3D HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + }, + { + .cap_id =3D HEADER_MODE, + .min =3D V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE, + .max =3D V4L2_MPEG_VIDEO_HEADER_MODE_JOINED_WITH_1ST_FRAME, + .step_or_mask =3D BIT(V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE) | + BIT(V4L2_MPEG_VIDEO_HEADER_MODE_JOINED_WITH_1ST_FRAME), + .value =3D V4L2_MPEG_VIDEO_HEADER_MODE_JOINED_WITH_1ST_FRAME, + .hfi_id =3D HFI_PROPERTY_CONFIG_VENC_SYNC_FRAME_SEQUENCE_HEADER, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + }, + { + .cap_id =3D BITRATE, + .min =3D BITRATE_MIN, + .max =3D BITRATE_MAX, + .step_or_mask =3D BITRATE_STEP, + .value =3D BITRATE_DEFAULT, + .hfi_id =3D HFI_PROPERTY_CONFIG_VENC_TARGET_BITRATE, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | + CAP_FLAG_DYNAMIC_ALLOWED, + }, + { + .cap_id =3D BITRATE_PEAK, + .min =3D BITRATE_MIN, + .max =3D BITRATE_MAX, + .step_or_mask =3D BITRATE_STEP, + .value =3D BITRATE_PEAK_DEFAULT, + .hfi_id =3D HFI_PROPERTY_CONFIG_VENC_MAX_BITRATE, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | + CAP_FLAG_DYNAMIC_ALLOWED, + }, + { + .cap_id =3D BITRATE_MODE, + .min =3D V4L2_MPEG_VIDEO_BITRATE_MODE_VBR, + .max =3D V4L2_MPEG_VIDEO_BITRATE_MODE_CBR, + .step_or_mask =3D BIT(V4L2_MPEG_VIDEO_BITRATE_MODE_VBR) | + BIT(V4L2_MPEG_VIDEO_BITRATE_MODE_CBR), + .value =3D V4L2_MPEG_VIDEO_BITRATE_MODE_VBR, + .hfi_id =3D HFI_PROPERTY_PARAM_VENC_RATE_CONTROL, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + }, + { + .cap_id =3D FRAME_SKIP_MODE, + .min =3D V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_DISABLED, + .max =3D V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT, + .step_or_mask =3D BIT(V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_DISABLED) | + BIT(V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT), + .value =3D V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_DISABLED, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + }, + { + .cap_id =3D FRAME_RC_ENABLE, + .min =3D 0, + .max =3D 1, + .step_or_mask =3D 1, + .value =3D 1, + }, + { + .cap_id =3D GOP_SIZE, + .min =3D 0, + .max =3D (1 << 16) - 1, + .step_or_mask =3D 1, + .value =3D 30, + }, + { + .cap_id =3D ENTROPY_MODE, + .min =3D V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CAVLC, + .max =3D V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CABAC, + .step_or_mask =3D BIT(V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CAVLC) | + BIT(V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CABAC), + .value =3D V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CAVLC, + .hfi_id =3D HFI_PROPERTY_PARAM_VENC_H264_ENTROPY_CONTROL, + .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + }, + { + .cap_id =3D MIN_FRAME_QP_H264, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D MIN_QP_8BIT, + .hfi_id =3D HFI_PROPERTY_PARAM_VENC_SESSION_QP_RANGE_V2, + .flags =3D CAP_FLAG_OUTPUT_PORT, + }, + { + .cap_id =3D MIN_FRAME_QP_HEVC, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP_HEVC, + .step_or_mask =3D 1, + .value =3D MIN_QP_8BIT, + .hfi_id =3D HFI_PROPERTY_PARAM_VENC_SESSION_QP_RANGE_V2, + .flags =3D CAP_FLAG_OUTPUT_PORT, + }, + { + .cap_id =3D MAX_FRAME_QP_H264, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP, + .step_or_mask =3D 1, + .value =3D MAX_QP, + .hfi_id =3D HFI_PROPERTY_PARAM_VENC_SESSION_QP_RANGE_V2, + .flags =3D CAP_FLAG_OUTPUT_PORT, + }, + { + .cap_id =3D MAX_FRAME_QP_HEVC, + .min =3D MIN_QP_8BIT, + .max =3D MAX_QP_HEVC, + .step_or_mask =3D 1, + .value =3D MAX_QP_HEVC, + .hfi_id =3D HFI_PROPERTY_PARAM_VENC_SESSION_QP_RANGE_V2, + .flags =3D CAP_FLAG_OUTPUT_PORT, + }, +}; + static struct platform_inst_caps platform_inst_cap_sm8250 =3D { .min_frame_width =3D 128, .max_frame_width =3D 8192, @@ -123,8 +310,10 @@ struct iris_platform_data sm8250_data =3D { .fwname =3D "qcom/vpu-1.0/venus.mbn", .pas_id =3D IRIS_PAS_ID, .inst_caps =3D &platform_inst_cap_sm8250, - .inst_fw_caps =3D inst_fw_cap_sm8250, - .inst_fw_caps_size =3D ARRAY_SIZE(inst_fw_cap_sm8250), + .inst_fw_caps_dec =3D inst_fw_cap_sm8250_dec, + .inst_fw_caps_dec_size =3D ARRAY_SIZE(inst_fw_cap_sm8250_dec), + .inst_fw_caps_enc =3D inst_fw_cap_sm8250_enc, + .inst_fw_caps_enc_size =3D ARRAY_SIZE(inst_fw_cap_sm8250_enc), .tz_cp_config_data =3D &tz_cp_config_sm8250, .hw_response_timeout =3D HW_RESPONSE_TIMEOUT_VALUE, .num_vpp_pipe =3D 4, diff --git a/drivers/media/platform/qcom/iris/iris_vdec.c b/drivers/media/p= latform/qcom/iris/iris_vdec.c index 0fb863426cdf479c50cad8a627c2845a6dfe0b32..ec7f06205e978fb71b6e2ff3241= c659585490bde 100644 --- a/drivers/media/platform/qcom/iris/iris_vdec.c +++ b/drivers/media/platform/qcom/iris/iris_vdec.c @@ -54,7 +54,7 @@ int iris_vdec_inst_init(struct iris_inst *inst) inst->buffers[BUF_OUTPUT].min_count =3D iris_vpu_buf_count(inst, BUF_OUTP= UT); inst->buffers[BUF_OUTPUT].size =3D f->fmt.pix_mp.plane_fmt[0].sizeimage; =20 - memcpy(&inst->fw_caps[0], &core->inst_fw_caps[0], + memcpy(&inst->fw_caps[0], &core->inst_fw_caps_dec[0], INST_FW_CAP_MAX * sizeof(struct platform_inst_fw_cap)); =20 return iris_ctrls_init(inst); diff --git a/drivers/media/platform/qcom/iris/iris_venc.c b/drivers/media/p= latform/qcom/iris/iris_venc.c index 11666f40a4d1c34e1b6eca0b5e40e0f09eeb2b67..4630ba12349a62a37515e93ed5e= fa2df197bce17 100644 --- a/drivers/media/platform/qcom/iris/iris_venc.c +++ b/drivers/media/platform/qcom/iris/iris_venc.c @@ -7,12 +7,14 @@ #include =20 #include "iris_buffer.h" +#include "iris_ctrls.h" #include "iris_instance.h" #include "iris_venc.h" #include "iris_vpu_buffer.h" =20 int iris_venc_inst_init(struct iris_inst *inst) { + struct iris_core *core =3D inst->core; struct v4l2_format *f; =20 inst->fmt_src =3D kzalloc(sizeof(*inst->fmt_src), GFP_KERNEL); @@ -61,7 +63,10 @@ int iris_venc_inst_init(struct iris_inst *inst) inst->operating_rate =3D DEFAULT_FPS << 16; inst->frame_rate =3D DEFAULT_FPS << 16; =20 - return 0; + memcpy(&inst->fw_caps[0], &core->inst_fw_caps_enc[0], + INST_FW_CAP_MAX * sizeof(struct platform_inst_fw_cap)); + + return iris_ctrls_init(inst); } =20 void iris_venc_inst_deinit(struct iris_inst *inst) --=20 2.34.1 From nobody Tue Oct 7 22:51:46 2025 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 12E212E3AF5; Fri, 4 Jul 2025 07:54:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615690; cv=none; b=Fo6lXDhEUN9Ee27u5SBlrSCgiGai/o1BZ8HXIw1L9zE/4Goyk42G71I8DfsUCpDYRn7bjNpc+MUrRWTZvQkS3hHfvzT13L/w81NEfQ7d1R7H4gSAtaVkWxbGj4ht3d5LsSUnFoUZgrTImfAr7vxxzQsfCfIQ9AGYvHA64pIawbo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615690; c=relaxed/simple; bh=H0emGSZvjZHGbi9LkzzLhpyLbUUdc4Bu8+NIUu88Frw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=XGh9WA/+YIzkjoyl4RVExnoPknS9eVZ6cf/XdHIJbU4/w8f65+AkLwSS213D1M0ozr6yDv/yw3fSiv7WFL5jYJxwBPg2H+kyQw27T+8QkvSuM/56SIYbG7kG7zMStlYBhUWWDW733KSBFTwOz2S5JE0D3dJ5an0Yf/eLLm1TKcg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=JCMPBlmh; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="JCMPBlmh" Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56475TCl032109; Fri, 4 Jul 2025 07:54:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= SIlHwq49NAxgIA37IWUJst1zjKLstnkvXg1Yaf2ZUug=; b=JCMPBlmhojPktjbY 3b7frQNRZAXsGekT9nYTXAR+E6jE/xcOXAiDAtqIhO2mKHNUahnLzMkLOHFoGL7/ /OfxFKCKpty6pP4AypXEaNR3h0M+h6A+Tww4BP13t5hkszTsCG+Althys0/u1UCX 2xwzGv0LOtxOZRDPjW3DG/HG7D2Vvf/heUJYANtHVqjsSkvhEaDGKNG68tyB6rh7 uxXgQbXFbGChoYSTKhw8IwxHeOa1na4EkDEpR3txrMCKJxgm8MQeqejQ8cd6eD46 yYtMIonbqk0rVTdsNWLH+EHJhcSKZoX35CPD2t13j4FXrDHEs4M9dNkkmC+wKjUJ nTsTlw== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 47j63kka4v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Jul 2025 07:54:35 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA05.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 5647sYpA025952 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 4 Jul 2025 07:54:34 GMT Received: from hu-dikshita-hyd.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Fri, 4 Jul 2025 00:54:31 -0700 From: Dikshita Agarwal Date: Fri, 4 Jul 2025 13:23:21 +0530 Subject: [PATCH 21/25] media: iris: Add V4L2 streaming support for encoder video device Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20250704-iris-video-encoder-v1-21-b6ce24e273cf@quicinc.com> References: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> In-Reply-To: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> To: Vikash Garodia , Abhinav Kumar , Bryan O'Donoghue , Mauro Carvalho Chehab , Hans Verkuil , Stefan Schmidt , "Vedang Nagar" CC: , , , Dikshita Agarwal X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1751615599; l=71251; i=quic_dikshita@quicinc.com; s=20240917; h=from:subject:message-id; bh=H0emGSZvjZHGbi9LkzzLhpyLbUUdc4Bu8+NIUu88Frw=; b=3rn9dqhr8AU2d3XRrV+Vhw8PwcqSH1X9Few7mdCUtlbDZ74qmgEd4ZXxjw++Z7+ppQoqI2gHh oXj4ifX8ZhLATS3vwb9wvrWCjC7mbEJ5GTwNyGTvpTyT+p4Uq5gp6n3 X-Developer-Key: i=quic_dikshita@quicinc.com; a=ed25519; pk=EEvKY6Ar1OI5SWf44FJ1Ebo1KuQEVbbf5UNPO+UHVhM= X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Authority-Analysis: v=2.4 cv=ZKfXmW7b c=1 sm=1 tr=0 ts=686788bb cx=c_pps a=JYp8KDb2vCoCEuGobkYCKw==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=GEpy-HfZoHoA:10 a=IkcTkHD0fZMA:10 a=Wb1JkmetP80A:10 a=COk6AnOGAAAA:8 a=6ax0HjhU0tIlWPuwGsYA:9 a=QEXdDO2ut3YA:10 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzA0MDA2MCBTYWx0ZWRfXxFUndKWnCu5J +kDunTssZ6JW7Xlk6SYXcisRIpUS7pE4bU+6EPjaqa6NFN12qwmwFXLDJ7YXOSH/T7pzIn83jJA LHd5USFXTtmXXilGoRyj+LXzYmS1qC2f6bE7F+yHF92Y7u323GgTSedlGF6dIOS2iwlzSJ44vfw Ewr6zc9vWIwyhei+SsQFgfaFkf5lOKtWG3SmzdWIAiF8Q8kxWrnK6N4gR63Do2hMXl8+I5+tD7Y myZLu3VpAKFLgo2wYGz63TSz4EXYTSTJmEGfAuUrvFuc4pKhhnrOvixh2m2BvgdP3rins2zVK2t c3j1onAuE3tyHQuQIsX+/CMs2yzg9u30p40G6kIRH0lhmaIbR5WtUutPPpNNcpoZqU0KLO1dLHe 3+qTL79oH1X8crYmY6xVg6tRjmUU7iNYI9/UJ/tyVWoKVdvdl6R1+kMZ+QkxpoyHy8CQJVfN X-Proofpoint-ORIG-GUID: fcoVxni0a7vBM2v-R2RzK4QcAiblXw-B X-Proofpoint-GUID: fcoVxni0a7vBM2v-R2RzK4QcAiblXw-B X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-04_03,2025-07-02_04,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxscore=0 mlxlogscore=999 spamscore=0 suspectscore=0 bulkscore=0 priorityscore=1501 lowpriorityscore=0 phishscore=0 impostorscore=0 malwarescore=0 clxscore=1015 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507040060 Add support for V4L2 streaming operations on the encoder video device. During stream-on, configure mandatory properties on the respective planes and notify the firmware to initiate an encode session. Signed-off-by: Dikshita Agarwal Tested-by: Vikash Garodia # X1E80100 --- drivers/media/platform/qcom/iris/Makefile | 4 +- drivers/media/platform/qcom/iris/iris_common.c | 196 ++++++++++++++ drivers/media/platform/qcom/iris/iris_common.h | 16 ++ drivers/media/platform/qcom/iris/iris_hfi_common.h | 2 +- .../platform/qcom/iris/iris_hfi_gen1_command.c | 281 ++++++++++++++---= ---- .../platform/qcom/iris/iris_hfi_gen1_defines.h | 18 ++ .../platform/qcom/iris/iris_hfi_gen2_command.c | 278 +++++++++++++----= --- .../platform/qcom/iris/iris_hfi_gen2_defines.h | 3 + .../platform/qcom/iris/iris_platform_common.h | 20 +- .../media/platform/qcom/iris/iris_platform_gen2.c | 92 +++++-- .../platform/qcom/iris/iris_platform_sm8250.c | 23 +- drivers/media/platform/qcom/iris/iris_vb2.c | 36 ++- drivers/media/platform/qcom/iris/iris_vdec.c | 190 +------------- drivers/media/platform/qcom/iris/iris_vdec.h | 1 - drivers/media/platform/qcom/iris/iris_venc.c | 32 +++ drivers/media/platform/qcom/iris/iris_venc.h | 2 + drivers/media/platform/qcom/iris/iris_vidc.c | 2 + 17 files changed, 782 insertions(+), 414 deletions(-) diff --git a/drivers/media/platform/qcom/iris/Makefile b/drivers/media/plat= form/qcom/iris/Makefile index ec32145e081b1fc3538dfa7d5113162a76a6068c..13270cd6d899852dded675b33d3= 7f5919b81ccba 100644 --- a/drivers/media/platform/qcom/iris/Makefile +++ b/drivers/media/platform/qcom/iris/Makefile @@ -1,5 +1,5 @@ -qcom-iris-objs +=3D \ - iris_buffer.o \ +qcom-iris-objs +=3D iris_buffer.o \ + iris_common.o \ iris_core.o \ iris_ctrls.o \ iris_firmware.o \ diff --git a/drivers/media/platform/qcom/iris/iris_common.c b/drivers/media= /platform/qcom/iris/iris_common.c new file mode 100644 index 0000000000000000000000000000000000000000..d6a9271bcec77f142919070bf05= 66d0cf8a39562 --- /dev/null +++ b/drivers/media/platform/qcom/iris/iris_common.c @@ -0,0 +1,196 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2022-2025 Qualcomm Innovation Center, Inc. All rights res= erved. + */ + +#include + +#include "iris_common.h" +#include "iris_ctrls.h" +#include "iris_instance.h" +#include "iris_power.h" + +int iris_process_streamon_input(struct iris_inst *inst) +{ + const struct iris_hfi_command_ops *hfi_ops =3D inst->core->hfi_ops; + enum iris_inst_sub_state set_sub_state =3D 0; + int ret; + + iris_scale_power(inst); + + ret =3D hfi_ops->session_start(inst, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); + if (ret) + return ret; + + if (inst->sub_state & IRIS_INST_SUB_INPUT_PAUSE) { + ret =3D iris_inst_change_sub_state(inst, IRIS_INST_SUB_INPUT_PAUSE, 0); + if (ret) + return ret; + } + + if (inst->domain =3D=3D DECODER && + (inst->sub_state & IRIS_INST_SUB_DRC || + inst->sub_state & IRIS_INST_SUB_DRAIN || + inst->sub_state & IRIS_INST_SUB_FIRST_IPSC)) { + if (!(inst->sub_state & IRIS_INST_SUB_INPUT_PAUSE)) { + if (hfi_ops->session_pause) { + ret =3D hfi_ops->session_pause(inst, + V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); + if (ret) + return ret; + } + set_sub_state =3D IRIS_INST_SUB_INPUT_PAUSE; + } + } + + ret =3D iris_inst_state_change_streamon(inst, V4L2_BUF_TYPE_VIDEO_OUTPUT_= MPLANE); + if (ret) + return ret; + + inst->last_buffer_dequeued =3D false; + + return iris_inst_change_sub_state(inst, 0, set_sub_state); +} + +int iris_process_streamon_output(struct iris_inst *inst) +{ + const struct iris_hfi_command_ops *hfi_ops =3D inst->core->hfi_ops; + bool drain_active =3D false, drc_active =3D false; + enum iris_inst_sub_state clear_sub_state =3D 0; + int ret =3D 0; + + iris_scale_power(inst); + + drain_active =3D inst->sub_state & IRIS_INST_SUB_DRAIN && + inst->sub_state & IRIS_INST_SUB_DRAIN_LAST; + + drc_active =3D inst->sub_state & IRIS_INST_SUB_DRC && + inst->sub_state & IRIS_INST_SUB_DRC_LAST; + + if (drc_active) + clear_sub_state =3D IRIS_INST_SUB_DRC | IRIS_INST_SUB_DRC_LAST; + else if (drain_active) + clear_sub_state =3D IRIS_INST_SUB_DRAIN | IRIS_INST_SUB_DRAIN_LAST; + + if (inst->domain =3D=3D DECODER && inst->sub_state & IRIS_INST_SUB_INPUT_= PAUSE) { + ret =3D iris_alloc_and_queue_input_int_bufs(inst); + if (ret) + return ret; + ret =3D iris_set_stage(inst, STAGE); + if (ret) + return ret; + ret =3D iris_set_pipe(inst, PIPE); + if (ret) + return ret; + } + + if (inst->state =3D=3D IRIS_INST_INPUT_STREAMING && + inst->sub_state & IRIS_INST_SUB_INPUT_PAUSE) { + if (!drain_active) + ret =3D hfi_ops->session_resume_drc(inst, + V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); + else if (hfi_ops->session_resume_drain) + ret =3D hfi_ops->session_resume_drain(inst, + V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); + if (ret) + return ret; + clear_sub_state |=3D IRIS_INST_SUB_INPUT_PAUSE; + } + + if (inst->sub_state & IRIS_INST_SUB_FIRST_IPSC) + clear_sub_state |=3D IRIS_INST_SUB_FIRST_IPSC; + + ret =3D hfi_ops->session_start(inst, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); + if (ret) + return ret; + + if (inst->sub_state & IRIS_INST_SUB_OUTPUT_PAUSE) + clear_sub_state |=3D IRIS_INST_SUB_OUTPUT_PAUSE; + + ret =3D iris_inst_state_change_streamon(inst, V4L2_BUF_TYPE_VIDEO_CAPTURE= _MPLANE); + if (ret) + return ret; + + inst->last_buffer_dequeued =3D false; + + return iris_inst_change_sub_state(inst, clear_sub_state, 0); +} + +static void iris_flush_deferred_buffers(struct iris_inst *inst, + enum iris_buffer_type type) +{ + struct v4l2_m2m_ctx *m2m_ctx =3D inst->m2m_ctx; + struct v4l2_m2m_buffer *buffer, *n; + struct iris_buffer *buf; + + if (type =3D=3D BUF_INPUT) { + v4l2_m2m_for_each_src_buf_safe(m2m_ctx, buffer, n) { + buf =3D to_iris_buffer(&buffer->vb); + if (buf->attr & BUF_ATTR_DEFERRED) { + if (!(buf->attr & BUF_ATTR_BUFFER_DONE)) { + buf->attr |=3D BUF_ATTR_BUFFER_DONE; + buf->data_size =3D 0; + iris_vb2_buffer_done(inst, buf); + } + } + } + } else { + v4l2_m2m_for_each_dst_buf_safe(m2m_ctx, buffer, n) { + buf =3D to_iris_buffer(&buffer->vb); + if (buf->attr & BUF_ATTR_DEFERRED) { + if (!(buf->attr & BUF_ATTR_BUFFER_DONE)) { + buf->attr |=3D BUF_ATTR_BUFFER_DONE; + buf->data_size =3D 0; + iris_vb2_buffer_done(inst, buf); + } + } + } + } +} + +static void iris_kill_session(struct iris_inst *inst) +{ + const struct iris_hfi_command_ops *hfi_ops =3D inst->core->hfi_ops; + + if (!inst->session_id) + return; + + hfi_ops->session_close(inst); + iris_inst_change_state(inst, IRIS_INST_ERROR); +} + +int iris_session_streamoff(struct iris_inst *inst, u32 plane) +{ + const struct iris_hfi_command_ops *hfi_ops =3D inst->core->hfi_ops; + enum iris_buffer_type buffer_type; + int ret; + + switch (plane) { + case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: + buffer_type =3D BUF_INPUT; + break; + case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: + buffer_type =3D BUF_OUTPUT; + break; + default: + return -EINVAL; + } + + ret =3D hfi_ops->session_stop(inst, plane); + if (ret) + goto error; + + ret =3D iris_inst_state_change_streamoff(inst, plane); + if (ret) + goto error; + + iris_flush_deferred_buffers(inst, buffer_type); + + return 0; + +error: + iris_kill_session(inst); + iris_flush_deferred_buffers(inst, buffer_type); + + return ret; +} diff --git a/drivers/media/platform/qcom/iris/iris_common.h b/drivers/media= /platform/qcom/iris/iris_common.h new file mode 100644 index 0000000000000000000000000000000000000000..f385eeb53910555f17602f3951e= 7a6e9636a9ba2 --- /dev/null +++ b/drivers/media/platform/qcom/iris/iris_common.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2022-2025 Qualcomm Innovation Center, Inc. All rights res= erved. + */ + +#ifndef __IRIS_COMMON_H__ +#define __IRIS_COMMON_H__ + +struct iris_inst; +struct iris_buffer; + +int iris_process_streamon_input(struct iris_inst *inst); +int iris_process_streamon_output(struct iris_inst *inst); +int iris_session_streamoff(struct iris_inst *inst, u32 plane); + +#endif diff --git a/drivers/media/platform/qcom/iris/iris_hfi_common.h b/drivers/m= edia/platform/qcom/iris/iris_hfi_common.h index 9e6aadb837830b46e4a68865583e28fc427cef0d..b51471fb32c70acee44c37f8e9d= ce0c6bc0b6ccc 100644 --- a/drivers/media/platform/qcom/iris/iris_hfi_common.h +++ b/drivers/media/platform/qcom/iris/iris_hfi_common.h @@ -102,7 +102,7 @@ enum hfi_matrix_coefficients { =20 struct iris_hfi_prop_type_handle { u32 type; - int (*handle)(struct iris_inst *inst); + int (*handle)(struct iris_inst *inst, u32 plane); }; =20 struct iris_hfi_command_ops { diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c b/dri= vers/media/platform/qcom/iris/iris_hfi_gen1_command.c index eae3dc5c596d1eb6090126ac391b8e0e2c9f09eb..fead3318743a09ecdc363eda4cb= f252f640eb6e0 100644 --- a/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c @@ -189,48 +189,75 @@ static int iris_hfi_gen1_session_stop(struct iris_ins= t *inst, u32 plane) u32 flush_type =3D 0; int ret =3D 0; =20 - if (((V4L2_TYPE_IS_OUTPUT(plane) && - inst->state =3D=3D IRIS_INST_INPUT_STREAMING) || - (V4L2_TYPE_IS_CAPTURE(plane) && - inst->state =3D=3D IRIS_INST_OUTPUT_STREAMING) || - inst->state =3D=3D IRIS_INST_ERROR) && - inst->sub_state & IRIS_INST_SUB_LOAD_RESOURCES) { - reinit_completion(&inst->completion); - iris_hfi_gen1_packet_session_cmd(inst, &pkt, HFI_CMD_SESSION_STOP); - ret =3D iris_hfi_queue_cmd_write(core, &pkt, pkt.shdr.hdr.size); - if (!ret) - ret =3D iris_wait_for_session_response(inst, false); - - reinit_completion(&inst->completion); - iris_hfi_gen1_packet_session_cmd(inst, &pkt, HFI_CMD_SESSION_RELEASE_RES= OURCES); - ret =3D iris_hfi_queue_cmd_write(core, &pkt, pkt.shdr.hdr.size); - if (!ret) - ret =3D iris_wait_for_session_response(inst, false); - - iris_inst_change_sub_state(inst, IRIS_INST_SUB_LOAD_RESOURCES, 0); + if (inst->domain =3D=3D DECODER) { + if (((V4L2_TYPE_IS_OUTPUT(plane) && + inst->state =3D=3D IRIS_INST_INPUT_STREAMING) || + (V4L2_TYPE_IS_CAPTURE(plane) && + inst->state =3D=3D IRIS_INST_OUTPUT_STREAMING) || + inst->state =3D=3D IRIS_INST_ERROR) && + inst->sub_state & IRIS_INST_SUB_LOAD_RESOURCES) { + reinit_completion(&inst->completion); + iris_hfi_gen1_packet_session_cmd(inst, &pkt, HFI_CMD_SESSION_STOP); + ret =3D iris_hfi_queue_cmd_write(core, &pkt, pkt.shdr.hdr.size); + if (!ret) + ret =3D iris_wait_for_session_response(inst, false); + + reinit_completion(&inst->completion); + iris_hfi_gen1_packet_session_cmd(inst, &pkt, + HFI_CMD_SESSION_RELEASE_RESOURCES); + ret =3D iris_hfi_queue_cmd_write(core, &pkt, pkt.shdr.hdr.size); + if (!ret) + ret =3D iris_wait_for_session_response(inst, false); + + iris_inst_change_sub_state(inst, IRIS_INST_SUB_LOAD_RESOURCES, 0); + + iris_helper_buffers_done(inst, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, + VB2_BUF_STATE_ERROR); + iris_helper_buffers_done(inst, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, + VB2_BUF_STATE_ERROR); + } else if (inst->state =3D=3D IRIS_INST_STREAMING) { + if (V4L2_TYPE_IS_OUTPUT(plane)) + flush_type =3D HFI_FLUSH_ALL; + else if (V4L2_TYPE_IS_CAPTURE(plane)) + flush_type =3D HFI_FLUSH_OUTPUT; + + reinit_completion(&inst->flush_completion); + + flush_pkt.shdr.hdr.size =3D sizeof(struct hfi_session_flush_pkt); + flush_pkt.shdr.hdr.pkt_type =3D HFI_CMD_SESSION_FLUSH; + flush_pkt.shdr.session_id =3D inst->session_id; + flush_pkt.flush_type =3D flush_type; + + ret =3D iris_hfi_queue_cmd_write(core, &flush_pkt, flush_pkt.shdr.hdr.s= ize); + if (!ret) { + inst->flush_responses_pending++; + ret =3D iris_wait_for_session_response(inst, true); + } + } + } else { + if (inst->state =3D=3D IRIS_INST_STREAMING || + inst->state =3D=3D IRIS_INST_INPUT_STREAMING || + inst->state =3D=3D IRIS_INST_ERROR) { + reinit_completion(&inst->completion); + iris_hfi_gen1_packet_session_cmd(inst, &pkt, HFI_CMD_SESSION_STOP); + ret =3D iris_hfi_queue_cmd_write(core, &pkt, pkt.shdr.hdr.size); + if (!ret) + ret =3D iris_wait_for_session_response(inst, false); + + reinit_completion(&inst->completion); + iris_hfi_gen1_packet_session_cmd(inst, &pkt, + HFI_CMD_SESSION_RELEASE_RESOURCES); + ret =3D iris_hfi_queue_cmd_write(core, &pkt, pkt.shdr.hdr.size); + if (!ret) + ret =3D iris_wait_for_session_response(inst, false); + + iris_inst_change_sub_state(inst, IRIS_INST_SUB_LOAD_RESOURCES, 0); + } =20 iris_helper_buffers_done(inst, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, VB2_BUF_STATE_ERROR); iris_helper_buffers_done(inst, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, VB2_BUF_STATE_ERROR); - } else if (inst->state =3D=3D IRIS_INST_STREAMING) { - if (V4L2_TYPE_IS_OUTPUT(plane)) - flush_type =3D HFI_FLUSH_ALL; - else if (V4L2_TYPE_IS_CAPTURE(plane)) - flush_type =3D HFI_FLUSH_OUTPUT; - - reinit_completion(&inst->flush_completion); - - flush_pkt.shdr.hdr.size =3D sizeof(struct hfi_session_flush_pkt); - flush_pkt.shdr.hdr.pkt_type =3D HFI_CMD_SESSION_FLUSH; - flush_pkt.shdr.session_id =3D inst->session_id; - flush_pkt.flush_type =3D flush_type; - - ret =3D iris_hfi_queue_cmd_write(core, &flush_pkt, flush_pkt.shdr.hdr.si= ze); - if (!ret) { - inst->flush_responses_pending++; - ret =3D iris_wait_for_session_response(inst, true); - } } =20 return ret; @@ -554,7 +581,7 @@ static int iris_hfi_gen1_session_set_property(struct ir= is_inst *inst, u32 packet return hfi_gen1_set_property(inst, packet_type, payload, payload_size); } =20 -static int iris_hfi_gen1_set_resolution(struct iris_inst *inst) +static int iris_hfi_gen1_set_resolution(struct iris_inst *inst, u32 plane) { u32 ptype =3D HFI_PROPERTY_PARAM_FRAME_SIZE; struct hfi_framesize fs; @@ -569,14 +596,18 @@ static int iris_hfi_gen1_set_resolution(struct iris_i= nst *inst) if (ret) return ret; } - fs.buffer_type =3D HFI_BUFFER_OUTPUT2; + if (inst->domain =3D=3D DECODER) + fs.buffer_type =3D HFI_BUFFER_OUTPUT2; + else + fs.buffer_type =3D HFI_BUFFER_OUTPUT; + fs.width =3D inst->fmt_dst->fmt.pix_mp.width; fs.height =3D inst->fmt_dst->fmt.pix_mp.height; =20 return hfi_gen1_set_property(inst, ptype, &fs, sizeof(fs)); } =20 -static int iris_hfi_gen1_decide_core(struct iris_inst *inst) +static int iris_hfi_gen1_decide_core(struct iris_inst *inst, u32 plane) { const u32 ptype =3D HFI_PROPERTY_CONFIG_VIDEOCORES_USAGE; struct hfi_videocores_usage_type cu; @@ -586,36 +617,45 @@ static int iris_hfi_gen1_decide_core(struct iris_inst= *inst) return hfi_gen1_set_property(inst, ptype, &cu, sizeof(cu)); } =20 -static int iris_hfi_gen1_set_raw_format(struct iris_inst *inst) +static int iris_hfi_gen1_set_raw_format(struct iris_inst *inst, u32 plane) { const u32 ptype =3D HFI_PROPERTY_PARAM_UNCOMPRESSED_FORMAT_SELECT; - u32 pixelformat =3D inst->fmt_dst->fmt.pix_mp.pixelformat; struct hfi_uncompressed_format_select fmt; + u32 pixelformat; int ret; =20 - if (iris_split_mode_enabled(inst)) { - fmt.buffer_type =3D HFI_BUFFER_OUTPUT; - fmt.format =3D pixelformat =3D=3D V4L2_PIX_FMT_NV12 ? HFI_COLOR_FORMAT_N= V12_UBWC : 0; + if (inst->domain =3D=3D DECODER) { + pixelformat =3D inst->fmt_dst->fmt.pix_mp.pixelformat; + if (iris_split_mode_enabled(inst)) { + fmt.buffer_type =3D HFI_BUFFER_OUTPUT; + fmt.format =3D pixelformat =3D=3D V4L2_PIX_FMT_NV12 ? + HFI_COLOR_FORMAT_NV12_UBWC : 0; =20 - ret =3D hfi_gen1_set_property(inst, ptype, &fmt, sizeof(fmt)); - if (ret) - return ret; + ret =3D hfi_gen1_set_property(inst, ptype, &fmt, sizeof(fmt)); + if (ret) + return ret; =20 - fmt.buffer_type =3D HFI_BUFFER_OUTPUT2; - fmt.format =3D pixelformat =3D=3D V4L2_PIX_FMT_NV12 ? HFI_COLOR_FORMAT_N= V12 : 0; + fmt.buffer_type =3D HFI_BUFFER_OUTPUT2; + fmt.format =3D pixelformat =3D=3D V4L2_PIX_FMT_NV12 ? HFI_COLOR_FORMAT_= NV12 : 0; =20 - ret =3D hfi_gen1_set_property(inst, ptype, &fmt, sizeof(fmt)); + ret =3D hfi_gen1_set_property(inst, ptype, &fmt, sizeof(fmt)); + } else { + fmt.buffer_type =3D HFI_BUFFER_OUTPUT; + fmt.format =3D pixelformat =3D=3D V4L2_PIX_FMT_NV12 ? HFI_COLOR_FORMAT_= NV12 : 0; + + ret =3D hfi_gen1_set_property(inst, ptype, &fmt, sizeof(fmt)); + } } else { - fmt.buffer_type =3D HFI_BUFFER_OUTPUT; + pixelformat =3D inst->fmt_src->fmt.pix_mp.pixelformat; + fmt.buffer_type =3D HFI_BUFFER_INPUT; fmt.format =3D pixelformat =3D=3D V4L2_PIX_FMT_NV12 ? HFI_COLOR_FORMAT_N= V12 : 0; - ret =3D hfi_gen1_set_property(inst, ptype, &fmt, sizeof(fmt)); } =20 return ret; } =20 -static int iris_hfi_gen1_set_format_constraints(struct iris_inst *inst) +static int iris_hfi_gen1_set_format_constraints(struct iris_inst *inst, u3= 2 plane) { const u32 ptype =3D HFI_PROPERTY_PARAM_UNCOMPRESSED_PLANE_ACTUAL_CONSTRAI= NTS_INFO; struct hfi_uncompressed_plane_actual_constraints_info pconstraint; @@ -635,7 +675,7 @@ static int iris_hfi_gen1_set_format_constraints(struct = iris_inst *inst) return hfi_gen1_set_property(inst, ptype, &pconstraint, sizeof(pconstrain= t)); } =20 -static int iris_hfi_gen1_set_num_bufs(struct iris_inst *inst) +static int iris_hfi_gen1_set_num_bufs(struct iris_inst *inst, u32 plane) { u32 ptype =3D HFI_PROPERTY_PARAM_BUFFER_COUNT_ACTUAL; struct hfi_buffer_count_actual buf_count; @@ -649,20 +689,28 @@ static int iris_hfi_gen1_set_num_bufs(struct iris_ins= t *inst) if (ret) return ret; =20 - if (iris_split_mode_enabled(inst)) { - buf_count.type =3D HFI_BUFFER_OUTPUT; - buf_count.count_actual =3D VIDEO_MAX_FRAME; - buf_count.count_min_host =3D VIDEO_MAX_FRAME; + if (inst->domain =3D=3D DECODER) { + if (iris_split_mode_enabled(inst)) { + buf_count.type =3D HFI_BUFFER_OUTPUT; + buf_count.count_actual =3D VIDEO_MAX_FRAME; + buf_count.count_min_host =3D VIDEO_MAX_FRAME; =20 - ret =3D hfi_gen1_set_property(inst, ptype, &buf_count, sizeof(buf_count)= ); - if (ret) - return ret; + ret =3D hfi_gen1_set_property(inst, ptype, &buf_count, sizeof(buf_count= )); + if (ret) + return ret; =20 - buf_count.type =3D HFI_BUFFER_OUTPUT2; - buf_count.count_actual =3D iris_vpu_buf_count(inst, BUF_DPB); - buf_count.count_min_host =3D iris_vpu_buf_count(inst, BUF_DPB); + buf_count.type =3D HFI_BUFFER_OUTPUT2; + buf_count.count_actual =3D iris_vpu_buf_count(inst, BUF_DPB); + buf_count.count_min_host =3D iris_vpu_buf_count(inst, BUF_DPB); =20 - ret =3D hfi_gen1_set_property(inst, ptype, &buf_count, sizeof(buf_count)= ); + ret =3D hfi_gen1_set_property(inst, ptype, &buf_count, sizeof(buf_count= )); + } else { + buf_count.type =3D HFI_BUFFER_OUTPUT; + buf_count.count_actual =3D VIDEO_MAX_FRAME; + buf_count.count_min_host =3D VIDEO_MAX_FRAME; + + ret =3D hfi_gen1_set_property(inst, ptype, &buf_count, sizeof(buf_count= )); + } } else { buf_count.type =3D HFI_BUFFER_OUTPUT; buf_count.count_actual =3D VIDEO_MAX_FRAME; @@ -674,7 +722,7 @@ static int iris_hfi_gen1_set_num_bufs(struct iris_inst = *inst) return ret; } =20 -static int iris_hfi_gen1_set_multistream(struct iris_inst *inst) +static int iris_hfi_gen1_set_multistream(struct iris_inst *inst, u32 plane) { u32 ptype =3D HFI_PROPERTY_PARAM_VDEC_MULTI_STREAM; struct hfi_multi_stream multi =3D {0}; @@ -709,7 +757,7 @@ static int iris_hfi_gen1_set_multistream(struct iris_in= st *inst) return ret; } =20 -static int iris_hfi_gen1_set_bufsize(struct iris_inst *inst) +static int iris_hfi_gen1_set_bufsize(struct iris_inst *inst, u32 plane) { const u32 ptype =3D HFI_PROPERTY_PARAM_BUFFER_SIZE_ACTUAL; struct hfi_buffer_size_actual bufsz; @@ -744,14 +792,49 @@ static int iris_hfi_gen1_set_bufsize(struct iris_inst= *inst) return ret; } =20 +static int iris_hfi_gen1_set_frame_rate(struct iris_inst *inst, u32 plane) +{ + const u32 ptype =3D HFI_PROPERTY_CONFIG_FRAME_RATE; + struct hfi_framerate frate; + + if (V4L2_TYPE_IS_OUTPUT(plane)) + return 0; + + frate.buffer_type =3D HFI_BUFFER_OUTPUT; + frate.framerate =3D inst->frame_rate; + + return hfi_gen1_set_property(inst, ptype, &frate, sizeof(frate)); +} + +static int iris_hfi_gen1_set_stride(struct iris_inst *inst, u32 plane) +{ + const u32 ptype =3D HFI_PROPERTY_PARAM_UNCOMPRESSED_PLANE_ACTUAL_INFO; + struct hfi_uncompressed_plane_actual_info plane_actual_info; + + plane_actual_info.buffer_type =3D HFI_BUFFER_INPUT; + plane_actual_info.num_planes =3D 2; + plane_actual_info.plane_format[0].actual_stride =3D + ALIGN(inst->fmt_src->fmt.pix_mp.width, 128); + plane_actual_info.plane_format[0].actual_plane_buffer_height =3D + ALIGN(inst->fmt_src->fmt.pix_mp.height, 32); + plane_actual_info.plane_format[1].actual_stride =3D + ALIGN(inst->fmt_src->fmt.pix_mp.width, 128); + plane_actual_info.plane_format[1].actual_plane_buffer_height =3D + (ALIGN(inst->fmt_src->fmt.pix_mp.height, 32)) / 2; + + return hfi_gen1_set_property(inst, ptype, &plane_actual_info, sizeof(plan= e_actual_info)); +} + static int iris_hfi_gen1_session_set_config_params(struct iris_inst *inst,= u32 plane) { + struct iris_hfi_prop_type_handle const *handler =3D NULL; + u32 handler_size =3D 0; struct iris_core *core =3D inst->core; u32 config_params_size, i, j; const u32 *config_params; int ret; =20 - static const struct iris_hfi_prop_type_handle prop_type_handle_inp_arr[] = =3D { + static const struct iris_hfi_prop_type_handle vdec_prop_type_handle_inp_a= rr[] =3D { {HFI_PROPERTY_PARAM_FRAME_SIZE, iris_hfi_gen1_set_resolution}, {HFI_PROPERTY_CONFIG_VIDEOCORES_USAGE, @@ -768,7 +851,7 @@ static int iris_hfi_gen1_session_set_config_params(stru= ct iris_inst *inst, u32 p iris_hfi_gen1_set_bufsize}, }; =20 - static const struct iris_hfi_prop_type_handle prop_type_handle_out_arr[] = =3D { + static const struct iris_hfi_prop_type_handle vdec_prop_type_handle_out_a= rr[] =3D { {HFI_PROPERTY_PARAM_FRAME_SIZE, iris_hfi_gen1_set_resolution}, {HFI_PROPERTY_PARAM_UNCOMPRESSED_FORMAT_SELECT, @@ -783,29 +866,43 @@ static int iris_hfi_gen1_session_set_config_params(st= ruct iris_inst *inst, u32 p iris_hfi_gen1_set_bufsize}, }; =20 - config_params =3D core->iris_platform_data->input_config_params_default; - config_params_size =3D core->iris_platform_data->input_config_params_defa= ult_size; - - if (V4L2_TYPE_IS_OUTPUT(plane)) { - for (i =3D 0; i < config_params_size; i++) { - for (j =3D 0; j < ARRAY_SIZE(prop_type_handle_inp_arr); j++) { - if (prop_type_handle_inp_arr[j].type =3D=3D config_params[i]) { - ret =3D prop_type_handle_inp_arr[j].handle(inst); - if (ret) - return ret; - break; - } - } + static const struct iris_hfi_prop_type_handle venc_prop_type_handle_inp_a= rr[] =3D { + {HFI_PROPERTY_CONFIG_FRAME_RATE, + iris_hfi_gen1_set_frame_rate}, + {HFI_PROPERTY_PARAM_UNCOMPRESSED_PLANE_ACTUAL_INFO, + iris_hfi_gen1_set_stride}, + {HFI_PROPERTY_PARAM_FRAME_SIZE, + iris_hfi_gen1_set_resolution}, + {HFI_PROPERTY_PARAM_UNCOMPRESSED_FORMAT_SELECT, + iris_hfi_gen1_set_raw_format}, + {HFI_PROPERTY_PARAM_BUFFER_COUNT_ACTUAL, + iris_hfi_gen1_set_num_bufs}, + }; + + if (inst->domain =3D=3D DECODER) { + config_params =3D core->iris_platform_data->dec_input_config_params_defa= ult; + config_params_size =3D core->iris_platform_data->dec_input_config_params= _default_size; + if (V4L2_TYPE_IS_OUTPUT(plane)) { + handler =3D vdec_prop_type_handle_inp_arr; + handler_size =3D ARRAY_SIZE(vdec_prop_type_handle_inp_arr); + } else if (V4L2_TYPE_IS_CAPTURE(plane)) { + handler =3D vdec_prop_type_handle_out_arr; + handler_size =3D ARRAY_SIZE(vdec_prop_type_handle_out_arr); } - } else if (V4L2_TYPE_IS_CAPTURE(plane)) { - for (i =3D 0; i < config_params_size; i++) { - for (j =3D 0; j < ARRAY_SIZE(prop_type_handle_out_arr); j++) { - if (prop_type_handle_out_arr[j].type =3D=3D config_params[i]) { - ret =3D prop_type_handle_out_arr[j].handle(inst); - if (ret) - return ret; - break; - } + } else { + config_params =3D core->iris_platform_data->enc_input_config_params; + config_params_size =3D core->iris_platform_data->enc_input_config_params= _size; + handler =3D venc_prop_type_handle_inp_arr; + handler_size =3D ARRAY_SIZE(venc_prop_type_handle_inp_arr); + } + + for (i =3D 0; i < config_params_size; i++) { + for (j =3D 0; j < handler_size; j++) { + if (handler[j].type =3D=3D config_params[i]) { + ret =3D handler[j].handle(inst, plane); + if (ret) + return ret; + break; } } } diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen1_defines.h b/dri= vers/media/platform/qcom/iris/iris_hfi_gen1_defines.h index f6e2db401daeee12106a07af62179ce0d1504c5c..dd6521bc2dfeab652ded11698a8= 8a9f850f01695 100644 --- a/drivers/media/platform/qcom/iris/iris_hfi_gen1_defines.h +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen1_defines.h @@ -82,10 +82,12 @@ #define HFI_PROPERTY_SYS_IMAGE_VERSION 0x6 =20 #define HFI_PROPERTY_PARAM_FRAME_SIZE 0x1001 +#define HFI_PROPERTY_PARAM_UNCOMPRESSED_PLANE_ACTUAL_INFO 0x1002 #define HFI_PROPERTY_PARAM_UNCOMPRESSED_FORMAT_SELECT 0x1003 #define HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT 0x1005 #define HFI_PROPERTY_PARAM_WORK_MODE 0x1015 #define HFI_PROPERTY_PARAM_WORK_ROUTE 0x1017 +#define HFI_PROPERTY_CONFIG_FRAME_RATE 0x2001 #define HFI_PROPERTY_CONFIG_VIDEOCORES_USAGE 0x2002 =20 #define HFI_PROPERTY_PARAM_VDEC_MULTI_STREAM 0x1003001 @@ -349,6 +351,17 @@ struct hfi_uncompressed_plane_actual_constraints_info { struct hfi_uncompressed_plane_constraints plane_format[2]; }; =20 +struct hfi_uncompressed_plane_actual { + int actual_stride; + u32 actual_plane_buffer_height; +}; + +struct hfi_uncompressed_plane_actual_info { + u32 buffer_type; + u32 num_planes; + struct hfi_uncompressed_plane_actual plane_format[2]; +}; + struct hfi_buffer_count_actual { u32 type; u32 count_actual; @@ -376,6 +389,11 @@ struct hfi_buffer_requirements { u32 alignment; }; =20 +struct hfi_framerate { + u32 buffer_type; + u32 framerate; +}; + struct hfi_event_data { u32 error; u32 height; diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c b/dri= vers/media/platform/qcom/iris/iris_hfi_gen2_command.c index 7ca5ae13d62b95fdcf71ef70cb6abf446b2c6e5a..4cdceca3f8a05a6ec9ad76e7cba= a138daba0e958 100644 --- a/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c @@ -88,15 +88,26 @@ static int iris_hfi_gen2_sys_pc_prep(struct iris_core *= core) return ret; } =20 -static u32 iris_hfi_gen2_get_port(u32 plane) +static u32 iris_hfi_gen2_get_port(struct iris_inst *inst, u32 plane) { - switch (plane) { - case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: - return HFI_PORT_BITSTREAM; - case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: - return HFI_PORT_RAW; - default: - return HFI_PORT_NONE; + if (inst->domain =3D=3D DECODER) { + switch (plane) { + case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: + return HFI_PORT_BITSTREAM; + case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: + return HFI_PORT_RAW; + default: + return HFI_PORT_NONE; + } + } else { + switch (plane) { + case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: + return HFI_PORT_RAW; + case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: + return HFI_PORT_BITSTREAM; + default: + return HFI_PORT_NONE; + } } } =20 @@ -136,34 +147,76 @@ static int iris_hfi_gen2_session_set_property(struct = iris_inst *inst, u32 packet inst_hfi_gen2->packet->size); } =20 -static int iris_hfi_gen2_set_bitstream_resolution(struct iris_inst *inst) +static int iris_hfi_gen2_set_raw_resolution(struct iris_inst *inst, u32 pl= ane) { - struct iris_inst_hfi_gen2 *inst_hfi_gen2 =3D to_iris_inst_hfi_gen2(inst); - u32 port =3D iris_hfi_gen2_get_port(V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); u32 resolution =3D inst->fmt_src->fmt.pix_mp.width << 16 | inst->fmt_src->fmt.pix_mp.height; + u32 port =3D iris_hfi_gen2_get_port(inst, plane); =20 - inst_hfi_gen2->src_subcr_params.bitstream_resolution =3D resolution; + return iris_hfi_gen2_session_set_property(inst, + HFI_PROP_RAW_RESOLUTION, + HFI_HOST_FLAGS_NONE, + port, + HFI_PAYLOAD_32_PACKED, + &resolution, + sizeof(u32)); +} + +static int iris_hfi_gen2_set_bitstream_resolution(struct iris_inst *inst, = u32 plane) +{ + struct iris_inst_hfi_gen2 *inst_hfi_gen2 =3D to_iris_inst_hfi_gen2(inst); + u32 port =3D iris_hfi_gen2_get_port(inst, plane); + enum hfi_packet_payload_info payload_type; + u32 resolution; + + if (inst->domain =3D=3D DECODER) { + resolution =3D inst->fmt_src->fmt.pix_mp.width << 16 | + inst->fmt_src->fmt.pix_mp.height; + inst_hfi_gen2->src_subcr_params.bitstream_resolution =3D resolution; + payload_type =3D HFI_PAYLOAD_U32; + } else { + resolution =3D inst->fmt_dst->fmt.pix_mp.width << 16 | + inst->fmt_dst->fmt.pix_mp.height; + inst_hfi_gen2->dst_subcr_params.bitstream_resolution =3D resolution; + payload_type =3D HFI_PAYLOAD_32_PACKED; + } =20 return iris_hfi_gen2_session_set_property(inst, HFI_PROP_BITSTREAM_RESOLUTION, HFI_HOST_FLAGS_NONE, port, - HFI_PAYLOAD_U32, + payload_type, &resolution, sizeof(u32)); } =20 -static int iris_hfi_gen2_set_crop_offsets(struct iris_inst *inst) +static int iris_hfi_gen2_set_crop_offsets(struct iris_inst *inst, u32 plan= e) { - u32 bottom_offset =3D (inst->fmt_src->fmt.pix_mp.height - inst->crop.heig= ht); - u32 right_offset =3D (inst->fmt_src->fmt.pix_mp.width - inst->crop.width); struct iris_inst_hfi_gen2 *inst_hfi_gen2 =3D to_iris_inst_hfi_gen2(inst); - u32 port =3D iris_hfi_gen2_get_port(V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); - u32 left_offset =3D inst->crop.left; - u32 top_offset =3D inst->crop.top; + u32 port =3D iris_hfi_gen2_get_port(inst, plane); + u32 bottom_offset, right_offset; + u32 left_offset, top_offset; u32 payload[2]; =20 + if (inst->domain =3D=3D DECODER) { + if (V4L2_TYPE_IS_OUTPUT(plane)) { + bottom_offset =3D (inst->fmt_src->fmt.pix_mp.height - inst->crop.height= ); + right_offset =3D (inst->fmt_src->fmt.pix_mp.width - inst->crop.width); + left_offset =3D inst->crop.left; + top_offset =3D inst->crop.top; + } else { + bottom_offset =3D (inst->fmt_dst->fmt.pix_mp.height - inst->compose.hei= ght); + right_offset =3D (inst->fmt_dst->fmt.pix_mp.width - inst->compose.width= ); + left_offset =3D inst->compose.left; + top_offset =3D inst->compose.top; + } + } else { + bottom_offset =3D (inst->fmt_src->fmt.pix_mp.height - inst->crop.height); + right_offset =3D (inst->fmt_src->fmt.pix_mp.width - inst->crop.width); + left_offset =3D inst->crop.left; + top_offset =3D inst->crop.top; + } + payload[0] =3D FIELD_PREP(GENMASK(31, 16), left_offset) | top_offset; payload[1] =3D FIELD_PREP(GENMASK(31, 16), right_offset) | bottom_offset; inst_hfi_gen2->src_subcr_params.crop_offsets[0] =3D payload[0]; @@ -178,10 +231,10 @@ static int iris_hfi_gen2_set_crop_offsets(struct iris= _inst *inst) sizeof(u64)); } =20 -static int iris_hfi_gen2_set_bit_depth(struct iris_inst *inst) +static int iris_hfi_gen2_set_bit_depth(struct iris_inst *inst, u32 plane) { struct iris_inst_hfi_gen2 *inst_hfi_gen2 =3D to_iris_inst_hfi_gen2(inst); - u32 port =3D iris_hfi_gen2_get_port(V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); + u32 port =3D iris_hfi_gen2_get_port(inst, plane); u32 bitdepth =3D BIT_DEPTH_8; =20 inst_hfi_gen2->src_subcr_params.bit_depth =3D bitdepth; @@ -195,10 +248,10 @@ static int iris_hfi_gen2_set_bit_depth(struct iris_in= st *inst) sizeof(u32)); } =20 -static int iris_hfi_gen2_set_coded_frames(struct iris_inst *inst) +static int iris_hfi_gen2_set_coded_frames(struct iris_inst *inst, u32 plan= e) { struct iris_inst_hfi_gen2 *inst_hfi_gen2 =3D to_iris_inst_hfi_gen2(inst); - u32 port =3D iris_hfi_gen2_get_port(V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); + u32 port =3D iris_hfi_gen2_get_port(inst, plane); u32 coded_frames =3D 0; =20 if (inst->fw_caps[CODED_FRAMES].value =3D=3D CODED_FRAMES_PROGRESSIVE) @@ -214,11 +267,11 @@ static int iris_hfi_gen2_set_coded_frames(struct iris= _inst *inst) sizeof(u32)); } =20 -static int iris_hfi_gen2_set_min_output_count(struct iris_inst *inst) +static int iris_hfi_gen2_set_min_output_count(struct iris_inst *inst, u32 = plane) { struct iris_inst_hfi_gen2 *inst_hfi_gen2 =3D to_iris_inst_hfi_gen2(inst); - u32 port =3D iris_hfi_gen2_get_port(V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); u32 min_output =3D inst->buffers[BUF_OUTPUT].min_count; + u32 port =3D iris_hfi_gen2_get_port(inst, plane); =20 inst_hfi_gen2->src_subcr_params.fw_min_count =3D min_output; =20 @@ -231,10 +284,10 @@ static int iris_hfi_gen2_set_min_output_count(struct = iris_inst *inst) sizeof(u32)); } =20 -static int iris_hfi_gen2_set_picture_order_count(struct iris_inst *inst) +static int iris_hfi_gen2_set_picture_order_count(struct iris_inst *inst, u= 32 plane) { struct iris_inst_hfi_gen2 *inst_hfi_gen2 =3D to_iris_inst_hfi_gen2(inst); - u32 port =3D iris_hfi_gen2_get_port(V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); + u32 port =3D iris_hfi_gen2_get_port(inst, plane); u32 poc =3D 0; =20 inst_hfi_gen2->src_subcr_params.pic_order_cnt =3D poc; @@ -248,16 +301,16 @@ static int iris_hfi_gen2_set_picture_order_count(stru= ct iris_inst *inst) sizeof(u32)); } =20 -static int iris_hfi_gen2_set_colorspace(struct iris_inst *inst) +static int iris_hfi_gen2_set_colorspace(struct iris_inst *inst, u32 plane) { struct iris_inst_hfi_gen2 *inst_hfi_gen2 =3D to_iris_inst_hfi_gen2(inst); - u32 port =3D iris_hfi_gen2_get_port(V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); struct v4l2_pix_format_mplane *pixmp =3D &inst->fmt_src->fmt.pix_mp; u32 video_signal_type_present_flag =3D 0, color_info; u32 matrix_coeff =3D HFI_MATRIX_COEFF_RESERVED; u32 video_format =3D UNSPECIFIED_COLOR_FORMAT; u32 full_range =3D V4L2_QUANTIZATION_DEFAULT; u32 transfer_char =3D HFI_TRANSFER_RESERVED; + u32 port =3D iris_hfi_gen2_get_port(inst, plane); u32 colour_description_present_flag =3D 0; u32 primaries =3D HFI_PRIMARIES_RESERVED; =20 @@ -291,10 +344,10 @@ static int iris_hfi_gen2_set_colorspace(struct iris_i= nst *inst) sizeof(u32)); } =20 -static int iris_hfi_gen2_set_profile(struct iris_inst *inst) +static int iris_hfi_gen2_set_profile(struct iris_inst *inst, u32 plane) { struct iris_inst_hfi_gen2 *inst_hfi_gen2 =3D to_iris_inst_hfi_gen2(inst); - u32 port =3D iris_hfi_gen2_get_port(V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); + u32 port =3D iris_hfi_gen2_get_port(inst, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLA= NE); u32 profile =3D 0; =20 switch (inst->codec) { @@ -320,10 +373,10 @@ static int iris_hfi_gen2_set_profile(struct iris_inst= *inst) sizeof(u32)); } =20 -static int iris_hfi_gen2_set_level(struct iris_inst *inst) +static int iris_hfi_gen2_set_level(struct iris_inst *inst, u32 plane) { struct iris_inst_hfi_gen2 *inst_hfi_gen2 =3D to_iris_inst_hfi_gen2(inst); - u32 port =3D iris_hfi_gen2_get_port(V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); + u32 port =3D iris_hfi_gen2_get_port(inst, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLA= NE); u32 level =3D 0; =20 switch (inst->codec) { @@ -349,33 +402,47 @@ static int iris_hfi_gen2_set_level(struct iris_inst *= inst) sizeof(u32)); } =20 -static int iris_hfi_gen2_set_colorformat(struct iris_inst *inst) +static int iris_hfi_gen2_set_colorformat(struct iris_inst *inst, u32 plane) { - u32 port =3D iris_hfi_gen2_get_port(V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); + u32 port =3D iris_hfi_gen2_get_port(inst, plane); u32 hfi_colorformat, pixelformat; =20 - pixelformat =3D inst->fmt_dst->fmt.pix_mp.pixelformat; - hfi_colorformat =3D pixelformat =3D=3D V4L2_PIX_FMT_NV12 ? HFI_COLOR_FMT_= NV12 : 0; + if (inst->domain =3D=3D DECODER) { + pixelformat =3D inst->fmt_dst->fmt.pix_mp.pixelformat; + hfi_colorformat =3D pixelformat =3D=3D V4L2_PIX_FMT_NV12 ? HFI_COLOR_FMT= _NV12 : 0; + } else { + pixelformat =3D inst->fmt_src->fmt.pix_mp.pixelformat; + hfi_colorformat =3D pixelformat =3D=3D V4L2_PIX_FMT_NV12 ? HFI_COLOR_FMT= _NV12 : 0; + } =20 return iris_hfi_gen2_session_set_property(inst, HFI_PROP_COLOR_FORMAT, HFI_HOST_FLAGS_NONE, port, - HFI_PAYLOAD_U32, + HFI_PAYLOAD_U32_ENUM, &hfi_colorformat, sizeof(u32)); } =20 -static int iris_hfi_gen2_set_linear_stride_scanline(struct iris_inst *inst) +static int iris_hfi_gen2_set_linear_stride_scanline(struct iris_inst *inst= , u32 plane) { - u32 port =3D iris_hfi_gen2_get_port(V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); - u32 pixelformat =3D inst->fmt_dst->fmt.pix_mp.pixelformat; - u32 scanline_y =3D inst->fmt_dst->fmt.pix_mp.height; - u32 stride_y =3D inst->fmt_dst->fmt.pix_mp.width; - u32 scanline_uv =3D scanline_y / 2; - u32 stride_uv =3D stride_y; + u32 pixelformat, stride_y, stride_uv, scanline_y, scanline_uv; + u32 port =3D iris_hfi_gen2_get_port(inst, plane); u32 payload[2]; =20 + if (inst->domain =3D=3D DECODER) { + pixelformat =3D inst->fmt_dst->fmt.pix_mp.pixelformat; + stride_y =3D inst->fmt_dst->fmt.pix_mp.width; + scanline_y =3D inst->fmt_dst->fmt.pix_mp.height; + } else { + pixelformat =3D inst->fmt_src->fmt.pix_mp.pixelformat; + stride_y =3D ALIGN(inst->fmt_src->fmt.pix_mp.width, 128); + scanline_y =3D ALIGN(inst->fmt_src->fmt.pix_mp.height, 32); + } + + stride_uv =3D stride_y; + scanline_uv =3D scanline_y / 2; + if (pixelformat !=3D V4L2_PIX_FMT_NV12) return 0; =20 @@ -386,15 +453,15 @@ static int iris_hfi_gen2_set_linear_stride_scanline(s= truct iris_inst *inst) HFI_PROP_LINEAR_STRIDE_SCANLINE, HFI_HOST_FLAGS_NONE, port, - HFI_PAYLOAD_U64, + HFI_PAYLOAD_64_PACKED, &payload, sizeof(u64)); } =20 -static int iris_hfi_gen2_set_tier(struct iris_inst *inst) +static int iris_hfi_gen2_set_tier(struct iris_inst *inst, u32 plane) { struct iris_inst_hfi_gen2 *inst_hfi_gen2 =3D to_iris_inst_hfi_gen2(inst); - u32 port =3D iris_hfi_gen2_get_port(V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); + u32 port =3D iris_hfi_gen2_get_port(inst, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLA= NE); u32 tier =3D inst->fw_caps[TIER].value; =20 inst_hfi_gen2->src_subcr_params.tier =3D tier; @@ -408,14 +475,28 @@ static int iris_hfi_gen2_set_tier(struct iris_inst *i= nst) sizeof(u32)); } =20 +static int iris_hfi_gen2_set_frame_rate(struct iris_inst *inst, u32 plane) +{ + u32 port =3D iris_hfi_gen2_get_port(inst, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPL= ANE); + + return iris_hfi_gen2_session_set_property(inst, + HFI_PROP_FRAME_RATE, + HFI_HOST_FLAGS_NONE, + port, + HFI_PAYLOAD_Q16, + &inst->frame_rate, + sizeof(u32)); +} + static int iris_hfi_gen2_session_set_config_params(struct iris_inst *inst,= u32 plane) { - struct iris_core *core =3D inst->core; + const struct iris_platform_data *pdata =3D inst->core->iris_platform_data; u32 config_params_size =3D 0, i, j; const u32 *config_params =3D NULL; int ret; =20 static const struct iris_hfi_prop_type_handle prop_type_handle_arr[] =3D { + {HFI_PROP_RAW_RESOLUTION, iris_hfi_gen2_set_raw_resolution = }, {HFI_PROP_BITSTREAM_RESOLUTION, iris_hfi_gen2_set_bitstream_resolu= tion }, {HFI_PROP_CROP_OFFSETS, iris_hfi_gen2_set_crop_offsets = }, {HFI_PROP_CODED_FRAMES, iris_hfi_gen2_set_coded_frames = }, @@ -428,29 +509,35 @@ static int iris_hfi_gen2_session_set_config_params(st= ruct iris_inst *inst, u32 p {HFI_PROP_COLOR_FORMAT, iris_hfi_gen2_set_colorformat = }, {HFI_PROP_LINEAR_STRIDE_SCANLINE, iris_hfi_gen2_set_linear_stride_sc= anline }, {HFI_PROP_TIER, iris_hfi_gen2_set_tier = }, + {HFI_PROP_FRAME_RATE, iris_hfi_gen2_set_frame_rate = }, }; =20 - if (V4L2_TYPE_IS_OUTPUT(plane)) { - switch (inst->codec) { - case V4L2_PIX_FMT_H264: - config_params =3D core->iris_platform_data->input_config_params_default; - config_params_size =3D - core->iris_platform_data->input_config_params_default_size; - break; - case V4L2_PIX_FMT_HEVC: - config_params =3D core->iris_platform_data->input_config_params_hevc; - config_params_size =3D - core->iris_platform_data->input_config_params_hevc_size; - break; - case V4L2_PIX_FMT_VP9: - config_params =3D core->iris_platform_data->input_config_params_vp9; - config_params_size =3D - core->iris_platform_data->input_config_params_vp9_size; - break; + if (inst->domain =3D=3D DECODER) { + if (V4L2_TYPE_IS_OUTPUT(plane)) { + if (inst->codec =3D=3D V4L2_PIX_FMT_H264) { + config_params =3D pdata->dec_input_config_params_default; + config_params_size =3D pdata->dec_input_config_params_default_size; + } else if (inst->codec =3D=3D V4L2_PIX_FMT_HEVC) { + config_params =3D pdata->dec_input_config_params_hevc; + config_params_size =3D pdata->dec_input_config_params_hevc_size; + } else if (inst->codec =3D=3D V4L2_PIX_FMT_VP9) { + config_params =3D pdata->dec_input_config_params_vp9; + config_params_size =3D pdata->dec_input_config_params_vp9_size; + } else { + return -EINVAL; + } + } else { + config_params =3D pdata->dec_output_config_params; + config_params_size =3D pdata->dec_output_config_params_size; } } else { - config_params =3D core->iris_platform_data->output_config_params; - config_params_size =3D core->iris_platform_data->output_config_params_si= ze; + if (V4L2_TYPE_IS_OUTPUT(plane)) { + config_params =3D pdata->enc_input_config_params; + config_params_size =3D pdata->enc_input_config_params_size; + } else { + config_params =3D pdata->enc_output_config_params; + config_params_size =3D pdata->enc_output_config_params_size; + } } =20 if (!config_params || !config_params_size) @@ -459,7 +546,7 @@ static int iris_hfi_gen2_session_set_config_params(stru= ct iris_inst *inst, u32 p for (i =3D 0; i < config_params_size; i++) { for (j =3D 0; j < ARRAY_SIZE(prop_type_handle_arr); j++) { if (prop_type_handle_arr[j].type =3D=3D config_params[i]) { - ret =3D prop_type_handle_arr[j].handle(inst); + ret =3D prop_type_handle_arr[j].handle(inst, plane); if (ret) return ret; break; @@ -477,14 +564,19 @@ static int iris_hfi_gen2_session_set_codec(struct iri= s_inst *inst) =20 switch (inst->codec) { case V4L2_PIX_FMT_H264: - codec =3D HFI_CODEC_DECODE_AVC; + if (inst->domain =3D=3D ENCODER) + codec =3D HFI_CODEC_ENCODE_AVC; + else + codec =3D HFI_CODEC_DECODE_AVC; break; case V4L2_PIX_FMT_HEVC: - codec =3D HFI_CODEC_DECODE_HEVC; + if (inst->domain =3D=3D ENCODER) + codec =3D HFI_CODEC_ENCODE_HEVC; + else + codec =3D HFI_CODEC_DECODE_HEVC; break; case V4L2_PIX_FMT_VP9: codec =3D HFI_CODEC_DECODE_VP9; - break; } =20 iris_hfi_gen2_packet_session_property(inst, @@ -550,9 +642,11 @@ static int iris_hfi_gen2_session_open(struct iris_inst= *inst) if (ret) goto fail_free_packet; =20 - ret =3D iris_hfi_gen2_session_set_default_header(inst); - if (ret) - goto fail_free_packet; + if (inst->domain =3D=3D DECODER) { + ret =3D iris_hfi_gen2_session_set_default_header(inst); + if (ret) + goto fail_free_packet; + } =20 return 0; =20 @@ -601,7 +695,7 @@ static int iris_hfi_gen2_session_subscribe_mode(struct = iris_inst *inst, cmd, (HFI_HOST_FLAGS_RESPONSE_REQUIRED | HFI_HOST_FLAGS_INTR_REQUIRED), - iris_hfi_gen2_get_port(plane), + iris_hfi_gen2_get_port(inst, plane), inst->session_id, payload_type, payload, @@ -623,6 +717,9 @@ static int iris_hfi_gen2_subscribe_change_param(struct = iris_inst *inst, u32 plan u32 hfi_port =3D 0, i; int ret; =20 + if (inst->domain =3D=3D ENCODER) + return 0; + if ((V4L2_TYPE_IS_OUTPUT(plane) && inst_hfi_gen2->ipsc_properties_set) || (V4L2_TYPE_IS_CAPTURE(plane) && inst_hfi_gen2->opsc_properties_set)) { dev_err(core->dev, "invalid plane\n"); @@ -631,19 +728,19 @@ static int iris_hfi_gen2_subscribe_change_param(struc= t iris_inst *inst, u32 plan =20 switch (inst->codec) { case V4L2_PIX_FMT_H264: - change_param =3D core->iris_platform_data->input_config_params_default; + change_param =3D core->iris_platform_data->dec_input_config_params_defau= lt; change_param_size =3D - core->iris_platform_data->input_config_params_default_size; + core->iris_platform_data->dec_input_config_params_default_size; break; case V4L2_PIX_FMT_HEVC: - change_param =3D core->iris_platform_data->input_config_params_hevc; + change_param =3D core->iris_platform_data->dec_input_config_params_hevc; change_param_size =3D - core->iris_platform_data->input_config_params_hevc_size; + core->iris_platform_data->dec_input_config_params_hevc_size; break; case V4L2_PIX_FMT_VP9: - change_param =3D core->iris_platform_data->input_config_params_vp9; + change_param =3D core->iris_platform_data->dec_input_config_params_vp9; change_param_size =3D - core->iris_platform_data->input_config_params_vp9_size; + core->iris_platform_data->dec_input_config_params_vp9_size; break; } =20 @@ -664,7 +761,7 @@ static int iris_hfi_gen2_subscribe_change_param(struct = iris_inst *inst, u32 plan if (V4L2_TYPE_IS_OUTPUT(plane)) { inst_hfi_gen2->ipsc_properties_set =3D true; } else { - hfi_port =3D iris_hfi_gen2_get_port(V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); + hfi_port =3D iris_hfi_gen2_get_port(inst, V4L2_BUF_TYPE_VIDEO_CAPTURE_MP= LANE); memcpy(&inst_hfi_gen2->dst_subcr_params, &inst_hfi_gen2->src_subcr_params, sizeof(inst_hfi_gen2->src_subcr_params)); @@ -759,6 +856,9 @@ static int iris_hfi_gen2_subscribe_property(struct iris= _inst *inst, u32 plane) =20 payload[0] =3D HFI_MODE_PROPERTY; =20 + if (inst->domain =3D=3D ENCODER) + return 0; + if (V4L2_TYPE_IS_OUTPUT(plane)) { subscribe_prop_size =3D core->iris_platform_data->dec_input_prop_size; subcribe_prop =3D core->iris_platform_data->dec_input_prop; @@ -810,7 +910,7 @@ static int iris_hfi_gen2_session_start(struct iris_inst= *inst, u32 plane) HFI_CMD_START, (HFI_HOST_FLAGS_RESPONSE_REQUIRED | HFI_HOST_FLAGS_INTR_REQUIRED), - iris_hfi_gen2_get_port(plane), + iris_hfi_gen2_get_port(inst, plane), inst->session_id, HFI_PAYLOAD_NONE, NULL, @@ -832,7 +932,7 @@ static int iris_hfi_gen2_session_stop(struct iris_inst = *inst, u32 plane) (HFI_HOST_FLAGS_RESPONSE_REQUIRED | HFI_HOST_FLAGS_INTR_REQUIRED | HFI_HOST_FLAGS_NON_DISCARDABLE), - iris_hfi_gen2_get_port(plane), + iris_hfi_gen2_get_port(inst, plane), inst->session_id, HFI_PAYLOAD_NONE, NULL, @@ -854,7 +954,7 @@ static int iris_hfi_gen2_session_pause(struct iris_inst= *inst, u32 plane) HFI_CMD_PAUSE, (HFI_HOST_FLAGS_RESPONSE_REQUIRED | HFI_HOST_FLAGS_INTR_REQUIRED), - iris_hfi_gen2_get_port(plane), + iris_hfi_gen2_get_port(inst, plane), inst->session_id, HFI_PAYLOAD_NONE, NULL, @@ -873,7 +973,7 @@ static int iris_hfi_gen2_session_resume_drc(struct iris= _inst *inst, u32 plane) HFI_CMD_RESUME, (HFI_HOST_FLAGS_RESPONSE_REQUIRED | HFI_HOST_FLAGS_INTR_REQUIRED), - iris_hfi_gen2_get_port(plane), + iris_hfi_gen2_get_port(inst, plane), inst->session_id, HFI_PAYLOAD_U32, &payload, @@ -892,7 +992,7 @@ static int iris_hfi_gen2_session_resume_drain(struct ir= is_inst *inst, u32 plane) HFI_CMD_RESUME, (HFI_HOST_FLAGS_RESPONSE_REQUIRED | HFI_HOST_FLAGS_INTR_REQUIRED), - iris_hfi_gen2_get_port(plane), + iris_hfi_gen2_get_port(inst, plane), inst->session_id, HFI_PAYLOAD_U32, &payload, @@ -914,7 +1014,7 @@ static int iris_hfi_gen2_session_drain(struct iris_ins= t *inst, u32 plane) (HFI_HOST_FLAGS_RESPONSE_REQUIRED | HFI_HOST_FLAGS_INTR_REQUIRED | HFI_HOST_FLAGS_NON_DISCARDABLE), - iris_hfi_gen2_get_port(plane), + iris_hfi_gen2_get_port(inst, plane), inst->session_id, HFI_PAYLOAD_NONE, NULL, diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen2_defines.h b/dri= vers/media/platform/qcom/iris/iris_hfi_gen2_defines.h index fb6724d7f95ff8858aa9ba093fefb642e89de279..b3d1c966958e516d940a7795e5c= be2f8e8bada57 100644 --- a/drivers/media/platform/qcom/iris/iris_hfi_gen2_defines.h +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen2_defines.h @@ -49,6 +49,7 @@ #define HFI_PROP_TIER 0x03000109 #define HFI_PROP_STAGE 0x0300010a #define HFI_PROP_PIPE 0x0300010b +#define HFI_PROP_FRAME_RATE 0x0300010c #define HFI_PROP_LUMA_CHROMA_BIT_DEPTH 0x0300010f #define HFI_PROP_CODED_FRAMES 0x03000120 #define HFI_PROP_CABAC_SESSION 0x03000121 @@ -69,6 +70,8 @@ #define HFI_PROP_DEC_DEFAULT_HEADER 0x03000168 #define HFI_PROP_DEC_START_FROM_RAP_FRAME 0x03000169 #define HFI_PROP_NO_OUTPUT 0x0300016a +#define HFI_PROP_BUFFER_MARK 0x0300016c +#define HFI_PROP_RAW_RESOLUTION 0x03000178 #define HFI_PROP_TOTAL_PEAK_BITRATE 0x0300017C #define HFI_PROP_COMV_BUFFER_COUNT 0x03000193 #define HFI_PROP_END 0x03FFFFFF diff --git a/drivers/media/platform/qcom/iris/iris_platform_common.h b/driv= ers/media/platform/qcom/iris/iris_platform_common.h index 49adb0a52bbf19849d0cc41179063b667a0ccb2f..f89dcd3347d8c95c14cee6192df= a91389da69d37 100644 --- a/drivers/media/platform/qcom/iris/iris_platform_common.h +++ b/drivers/media/platform/qcom/iris/iris_platform_common.h @@ -222,14 +222,18 @@ struct iris_platform_data { u32 max_core_mbpf; /* max number of macroblocks per second supported */ u32 max_core_mbps; - const u32 *input_config_params_default; - unsigned int input_config_params_default_size; - const u32 *input_config_params_hevc; - unsigned int input_config_params_hevc_size; - const u32 *input_config_params_vp9; - unsigned int input_config_params_vp9_size; - const u32 *output_config_params; - unsigned int output_config_params_size; + const u32 *dec_input_config_params_default; + unsigned int dec_input_config_params_default_size; + const u32 *dec_input_config_params_hevc; + unsigned int dec_input_config_params_hevc_size; + const u32 *dec_input_config_params_vp9; + unsigned int dec_input_config_params_vp9_size; + const u32 *dec_output_config_params; + unsigned int dec_output_config_params_size; + const u32 *enc_input_config_params; + unsigned int enc_input_config_params_size; + const u32 *enc_output_config_params; + unsigned int enc_output_config_params_size; const u32 *dec_input_prop; unsigned int dec_input_prop_size; const u32 *dec_output_prop_avc; diff --git a/drivers/media/platform/qcom/iris/iris_platform_gen2.c b/driver= s/media/platform/qcom/iris/iris_platform_gen2.c index 04e76445dd9141285a6e48be76bdf1bdb51f0cee..bfafd7c436116423bd3e8ecd4cf= 24038e383d2c8 100644 --- a/drivers/media/platform/qcom/iris/iris_platform_gen2.c +++ b/drivers/media/platform/qcom/iris/iris_platform_gen2.c @@ -638,11 +638,25 @@ static const u32 sm8550_vdec_input_config_param_vp9[]= =3D { HFI_PROP_LEVEL, }; =20 +static const u32 sm8550_venc_input_config_params[] =3D { + HFI_PROP_COLOR_FORMAT, + HFI_PROP_RAW_RESOLUTION, + HFI_PROP_CROP_OFFSETS, + HFI_PROP_LINEAR_STRIDE_SCANLINE, + HFI_PROP_SIGNAL_COLOR_INFO, +}; + static const u32 sm8550_vdec_output_config_params[] =3D { HFI_PROP_COLOR_FORMAT, HFI_PROP_LINEAR_STRIDE_SCANLINE, }; =20 +static const u32 sm8550_venc_output_config_params[] =3D { + HFI_PROP_BITSTREAM_RESOLUTION, + HFI_PROP_CROP_OFFSETS, + HFI_PROP_FRAME_RATE, +}; + static const u32 sm8550_vdec_subscribe_input_properties[] =3D { HFI_PROP_NO_OUTPUT, }; @@ -706,22 +720,32 @@ struct iris_platform_data sm8550_data =3D { .max_session_count =3D 16, .max_core_mbpf =3D NUM_MBS_8K * 2, .max_core_mbps =3D ((7680 * 4320) / 256) * 60, - .input_config_params_default =3D + .dec_input_config_params_default =3D sm8550_vdec_input_config_params_default, - .input_config_params_default_size =3D + .dec_input_config_params_default_size =3D ARRAY_SIZE(sm8550_vdec_input_config_params_default), - .input_config_params_hevc =3D + .dec_input_config_params_hevc =3D sm8550_vdec_input_config_param_hevc, - .input_config_params_hevc_size =3D + .dec_input_config_params_hevc_size =3D ARRAY_SIZE(sm8550_vdec_input_config_param_hevc), - .input_config_params_vp9 =3D + .dec_input_config_params_vp9 =3D sm8550_vdec_input_config_param_vp9, - .input_config_params_vp9_size =3D + .dec_input_config_params_vp9_size =3D ARRAY_SIZE(sm8550_vdec_input_config_param_vp9), - .output_config_params =3D + .dec_output_config_params =3D sm8550_vdec_output_config_params, - .output_config_params_size =3D + .dec_output_config_params_size =3D ARRAY_SIZE(sm8550_vdec_output_config_params), + + .enc_input_config_params =3D + sm8550_venc_input_config_params, + .enc_input_config_params_size =3D + ARRAY_SIZE(sm8550_venc_input_config_params), + .enc_output_config_params =3D + sm8550_venc_output_config_params, + .enc_output_config_params_size =3D + ARRAY_SIZE(sm8550_venc_output_config_params), + .dec_input_prop =3D sm8550_vdec_subscribe_input_properties, .dec_input_prop_size =3D ARRAY_SIZE(sm8550_vdec_subscribe_input_propertie= s), .dec_output_prop_avc =3D sm8550_vdec_subscribe_output_properties_avc, @@ -784,22 +808,32 @@ struct iris_platform_data sm8650_data =3D { .max_session_count =3D 16, .max_core_mbpf =3D NUM_MBS_8K * 2, .max_core_mbps =3D ((7680 * 4320) / 256) * 60, - .input_config_params_default =3D + .dec_input_config_params_default =3D sm8550_vdec_input_config_params_default, - .input_config_params_default_size =3D + .dec_input_config_params_default_size =3D ARRAY_SIZE(sm8550_vdec_input_config_params_default), - .input_config_params_hevc =3D + .dec_input_config_params_hevc =3D sm8550_vdec_input_config_param_hevc, - .input_config_params_hevc_size =3D + .dec_input_config_params_hevc_size =3D ARRAY_SIZE(sm8550_vdec_input_config_param_hevc), - .input_config_params_vp9 =3D + .dec_input_config_params_vp9 =3D sm8550_vdec_input_config_param_vp9, - .input_config_params_vp9_size =3D + .dec_input_config_params_vp9_size =3D ARRAY_SIZE(sm8550_vdec_input_config_param_vp9), - .output_config_params =3D + .dec_output_config_params =3D sm8550_vdec_output_config_params, - .output_config_params_size =3D + .dec_output_config_params_size =3D ARRAY_SIZE(sm8550_vdec_output_config_params), + + .enc_input_config_params =3D + sm8550_venc_input_config_params, + .enc_input_config_params_size =3D + ARRAY_SIZE(sm8550_venc_input_config_params), + .enc_output_config_params =3D + sm8550_venc_output_config_params, + .enc_output_config_params_size =3D + ARRAY_SIZE(sm8550_venc_output_config_params), + .dec_input_prop =3D sm8550_vdec_subscribe_input_properties, .dec_input_prop_size =3D ARRAY_SIZE(sm8550_vdec_subscribe_input_propertie= s), .dec_output_prop_avc =3D sm8550_vdec_subscribe_output_properties_avc, @@ -858,22 +892,32 @@ struct iris_platform_data qcs8300_data =3D { .max_session_count =3D 16, .max_core_mbpf =3D ((4096 * 2176) / 256) * 4, .max_core_mbps =3D (((3840 * 2176) / 256) * 120), - .input_config_params_default =3D + .dec_input_config_params_default =3D sm8550_vdec_input_config_params_default, - .input_config_params_default_size =3D + .dec_input_config_params_default_size =3D ARRAY_SIZE(sm8550_vdec_input_config_params_default), - .input_config_params_hevc =3D + .dec_input_config_params_hevc =3D sm8550_vdec_input_config_param_hevc, - .input_config_params_hevc_size =3D + .dec_input_config_params_hevc_size =3D ARRAY_SIZE(sm8550_vdec_input_config_param_hevc), - .input_config_params_vp9 =3D + .dec_input_config_params_vp9 =3D sm8550_vdec_input_config_param_vp9, - .input_config_params_vp9_size =3D + .dec_input_config_params_vp9_size =3D ARRAY_SIZE(sm8550_vdec_input_config_param_vp9), - .output_config_params =3D + .dec_output_config_params =3D sm8550_vdec_output_config_params, - .output_config_params_size =3D + .dec_output_config_params_size =3D ARRAY_SIZE(sm8550_vdec_output_config_params), + + .enc_input_config_params =3D + sm8550_venc_input_config_params, + .enc_input_config_params_size =3D + ARRAY_SIZE(sm8550_venc_input_config_params), + .enc_output_config_params =3D + sm8550_venc_output_config_params, + .enc_output_config_params_size =3D + ARRAY_SIZE(sm8550_venc_output_config_params), + .dec_input_prop =3D sm8550_vdec_subscribe_input_properties, .dec_input_prop_size =3D ARRAY_SIZE(sm8550_vdec_subscribe_input_propertie= s), .dec_output_prop_avc =3D sm8550_vdec_subscribe_output_properties_avc, diff --git a/drivers/media/platform/qcom/iris/iris_platform_sm8250.c b/driv= ers/media/platform/qcom/iris/iris_platform_sm8250.c index 4f083eac261fff5642f15c4fc2f0f9f942818cac..34960d250d09dd872749dd19cdd= 3316e94575b81 100644 --- a/drivers/media/platform/qcom/iris/iris_platform_sm8250.c +++ b/drivers/media/platform/qcom/iris/iris_platform_sm8250.c @@ -38,6 +38,14 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8250_de= c[] =3D { }; =20 static struct platform_inst_fw_cap inst_fw_cap_sm8250_enc[] =3D { + { + .cap_id =3D STAGE, + .min =3D STAGE_1, + .max =3D STAGE_2, + .step_or_mask =3D 1, + .value =3D STAGE_2, + .hfi_id =3D HFI_PROPERTY_PARAM_WORK_MODE, + }, { .cap_id =3D PROFILE_H264, .min =3D V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE, @@ -278,6 +286,14 @@ static const u32 sm8250_vdec_input_config_param_defaul= t[] =3D { HFI_PROPERTY_PARAM_BUFFER_ALLOC_MODE, }; =20 +static const u32 sm8250_venc_input_config_param[] =3D { + HFI_PROPERTY_CONFIG_FRAME_RATE, + HFI_PROPERTY_PARAM_UNCOMPRESSED_PLANE_ACTUAL_INFO, + HFI_PROPERTY_PARAM_FRAME_SIZE, + HFI_PROPERTY_PARAM_UNCOMPRESSED_FORMAT_SELECT, + HFI_PROPERTY_PARAM_BUFFER_COUNT_ACTUAL, +}; + static const u32 sm8250_dec_ip_int_buf_tbl[] =3D { BUF_BIN, BUF_SCRATCH_1, @@ -320,10 +336,13 @@ struct iris_platform_data sm8250_data =3D { .max_session_count =3D 16, .max_core_mbpf =3D NUM_MBS_8K, .max_core_mbps =3D ((7680 * 4320) / 256) * 60, - .input_config_params_default =3D + .dec_input_config_params_default =3D sm8250_vdec_input_config_param_default, - .input_config_params_default_size =3D + .dec_input_config_params_default_size =3D ARRAY_SIZE(sm8250_vdec_input_config_param_default), + .enc_input_config_params =3D sm8250_venc_input_config_param, + .enc_input_config_params_size =3D + ARRAY_SIZE(sm8250_venc_input_config_param), =20 .dec_ip_int_buf_tbl =3D sm8250_dec_ip_int_buf_tbl, .dec_ip_int_buf_tbl_size =3D ARRAY_SIZE(sm8250_dec_ip_int_buf_tbl), diff --git a/drivers/media/platform/qcom/iris/iris_vb2.c b/drivers/media/pl= atform/qcom/iris/iris_vb2.c index e32f7e1f007228a3b2b51cd76cd193d852f16080..fbf8ebb74193284dc847c54f76f= 908656b3098c9 100644 --- a/drivers/media/platform/qcom/iris/iris_vb2.c +++ b/drivers/media/platform/qcom/iris/iris_vb2.c @@ -7,9 +7,11 @@ #include #include =20 +#include "iris_common.h" #include "iris_instance.h" #include "iris_vb2.h" #include "iris_vdec.h" +#include "iris_venc.h" #include "iris_power.h" =20 static int iris_check_inst_mbpf(struct iris_inst *inst) @@ -174,19 +176,35 @@ int iris_vb2_start_streaming(struct vb2_queue *q, uns= igned int count) if (ret) goto error; =20 - if (V4L2_TYPE_IS_OUTPUT(q->type)) - ret =3D iris_vdec_streamon_input(inst); - else if (V4L2_TYPE_IS_CAPTURE(q->type)) - ret =3D iris_vdec_streamon_output(inst); + if (V4L2_TYPE_IS_OUTPUT(q->type)) { + if (inst->domain =3D=3D DECODER) + ret =3D iris_vdec_streamon_input(inst); + else + ret =3D iris_venc_streamon_input(inst); + } else if (V4L2_TYPE_IS_CAPTURE(q->type)) { + if (inst->domain =3D=3D DECODER) + ret =3D iris_vdec_streamon_output(inst); + else + ret =3D iris_venc_streamon_output(inst); + } if (ret) goto error; =20 buf_type =3D iris_v4l2_type_to_driver(q->type); =20 - if (inst->state =3D=3D IRIS_INST_STREAMING) - ret =3D iris_queue_internal_deferred_buffers(inst, BUF_DPB); - if (!ret) - ret =3D iris_queue_deferred_buffers(inst, buf_type); + if (inst->domain =3D=3D DECODER) { + if (inst->state =3D=3D IRIS_INST_STREAMING) + ret =3D iris_queue_internal_deferred_buffers(inst, BUF_DPB); + if (!ret) + ret =3D iris_queue_deferred_buffers(inst, buf_type); + } else { + if (inst->state =3D=3D IRIS_INST_STREAMING) { + ret =3D iris_queue_deferred_buffers(inst, BUF_INPUT); + if (!ret) + ret =3D iris_queue_deferred_buffers(inst, BUF_OUTPUT); + } + } + if (ret) goto error; =20 @@ -218,7 +236,7 @@ void iris_vb2_stop_streaming(struct vb2_queue *q) !V4L2_TYPE_IS_CAPTURE(q->type)) goto exit; =20 - ret =3D iris_vdec_session_streamoff(inst, q->type); + ret =3D iris_session_streamoff(inst, q->type); if (ret) goto exit; =20 diff --git a/drivers/media/platform/qcom/iris/iris_vdec.c b/drivers/media/p= latform/qcom/iris/iris_vdec.c index ec7f06205e978fb71b6e2ff3241c659585490bde..f091ef45d2a5f93db066dd13aff= f42b26e8b0155 100644 --- a/drivers/media/platform/qcom/iris/iris_vdec.c +++ b/drivers/media/platform/qcom/iris/iris_vdec.c @@ -7,6 +7,7 @@ #include =20 #include "iris_buffer.h" +#include "iris_common.h" #include "iris_ctrls.h" #include "iris_instance.h" #include "iris_power.h" @@ -312,125 +313,6 @@ void iris_vdec_src_change(struct iris_inst *inst) v4l2_event_queue_fh(&inst->fh, &event); } =20 - -static void iris_vdec_flush_deferred_buffers(struct iris_inst *inst, - enum iris_buffer_type type) -{ - struct v4l2_m2m_ctx *m2m_ctx =3D inst->m2m_ctx; - struct v4l2_m2m_buffer *buffer, *n; - struct iris_buffer *buf; - - if (type =3D=3D BUF_INPUT) { - v4l2_m2m_for_each_src_buf_safe(m2m_ctx, buffer, n) { - buf =3D to_iris_buffer(&buffer->vb); - if (buf->attr & BUF_ATTR_DEFERRED) { - if (!(buf->attr & BUF_ATTR_BUFFER_DONE)) { - buf->attr |=3D BUF_ATTR_BUFFER_DONE; - buf->data_size =3D 0; - iris_vb2_buffer_done(inst, buf); - } - } - } - } else { - v4l2_m2m_for_each_dst_buf_safe(m2m_ctx, buffer, n) { - buf =3D to_iris_buffer(&buffer->vb); - if (buf->attr & BUF_ATTR_DEFERRED) { - if (!(buf->attr & BUF_ATTR_BUFFER_DONE)) { - buf->attr |=3D BUF_ATTR_BUFFER_DONE; - buf->data_size =3D 0; - iris_vb2_buffer_done(inst, buf); - } - } - } - } -} - -static void iris_vdec_kill_session(struct iris_inst *inst) -{ - const struct iris_hfi_command_ops *hfi_ops =3D inst->core->hfi_ops; - - if (!inst->session_id) - return; - - hfi_ops->session_close(inst); - iris_inst_change_state(inst, IRIS_INST_ERROR); -} - -int iris_vdec_session_streamoff(struct iris_inst *inst, u32 plane) -{ - const struct iris_hfi_command_ops *hfi_ops =3D inst->core->hfi_ops; - enum iris_buffer_type buffer_type; - int ret; - - switch (plane) { - case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: - buffer_type =3D BUF_INPUT; - break; - case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: - buffer_type =3D BUF_OUTPUT; - break; - default: - return -EINVAL; - } - - ret =3D hfi_ops->session_stop(inst, plane); - if (ret) - goto error; - - ret =3D iris_inst_state_change_streamoff(inst, plane); - if (ret) - goto error; - - iris_vdec_flush_deferred_buffers(inst, buffer_type); - - return 0; - -error: - iris_vdec_kill_session(inst); - iris_vdec_flush_deferred_buffers(inst, buffer_type); - - return ret; -} - -static int iris_vdec_process_streamon_input(struct iris_inst *inst) -{ - const struct iris_hfi_command_ops *hfi_ops =3D inst->core->hfi_ops; - enum iris_inst_sub_state set_sub_state =3D 0; - int ret; - - iris_scale_power(inst); - - ret =3D hfi_ops->session_start(inst, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); - if (ret) - return ret; - - if (inst->sub_state & IRIS_INST_SUB_INPUT_PAUSE) { - ret =3D iris_inst_change_sub_state(inst, IRIS_INST_SUB_INPUT_PAUSE, 0); - if (ret) - return ret; - } - - if (inst->sub_state & IRIS_INST_SUB_DRC || - inst->sub_state & IRIS_INST_SUB_DRAIN || - inst->sub_state & IRIS_INST_SUB_FIRST_IPSC) { - if (!(inst->sub_state & IRIS_INST_SUB_INPUT_PAUSE)) { - if (hfi_ops->session_pause) { - ret =3D hfi_ops->session_pause(inst, - V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); - if (ret) - return ret; - } - set_sub_state =3D IRIS_INST_SUB_INPUT_PAUSE; - } - } - - ret =3D iris_inst_state_change_streamon(inst, V4L2_BUF_TYPE_VIDEO_OUTPUT_= MPLANE); - if (ret) - return ret; - - return iris_inst_change_sub_state(inst, 0, set_sub_state); -} - int iris_vdec_streamon_input(struct iris_inst *inst) { int ret; @@ -457,71 +339,7 @@ int iris_vdec_streamon_input(struct iris_inst *inst) if (ret) return ret; =20 - return iris_vdec_process_streamon_input(inst); -} - -static int iris_vdec_process_streamon_output(struct iris_inst *inst) -{ - const struct iris_hfi_command_ops *hfi_ops =3D inst->core->hfi_ops; - bool drain_active =3D false, drc_active =3D false; - enum iris_inst_sub_state clear_sub_state =3D 0; - int ret =3D 0; - - iris_scale_power(inst); - - drain_active =3D inst->sub_state & IRIS_INST_SUB_DRAIN && - inst->sub_state & IRIS_INST_SUB_DRAIN_LAST; - - drc_active =3D inst->sub_state & IRIS_INST_SUB_DRC && - inst->sub_state & IRIS_INST_SUB_DRC_LAST; - - if (drc_active) - clear_sub_state =3D IRIS_INST_SUB_DRC | IRIS_INST_SUB_DRC_LAST; - else if (drain_active) - clear_sub_state =3D IRIS_INST_SUB_DRAIN | IRIS_INST_SUB_DRAIN_LAST; - - if (inst->sub_state & IRIS_INST_SUB_INPUT_PAUSE) { - ret =3D iris_alloc_and_queue_input_int_bufs(inst); - if (ret) - return ret; - ret =3D iris_set_stage(inst, STAGE); - if (ret) - return ret; - ret =3D iris_set_pipe(inst, PIPE); - if (ret) - return ret; - } - - if (inst->state =3D=3D IRIS_INST_INPUT_STREAMING && - inst->sub_state & IRIS_INST_SUB_INPUT_PAUSE) { - if (!drain_active) - ret =3D hfi_ops->session_resume_drc(inst, - V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); - else if (hfi_ops->session_resume_drain) - ret =3D hfi_ops->session_resume_drain(inst, - V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); - if (ret) - return ret; - clear_sub_state |=3D IRIS_INST_SUB_INPUT_PAUSE; - } - - if (inst->sub_state & IRIS_INST_SUB_FIRST_IPSC) - clear_sub_state |=3D IRIS_INST_SUB_FIRST_IPSC; - - ret =3D hfi_ops->session_start(inst, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); - if (ret) - return ret; - - if (inst->sub_state & IRIS_INST_SUB_OUTPUT_PAUSE) - clear_sub_state |=3D IRIS_INST_SUB_OUTPUT_PAUSE; - - ret =3D iris_inst_state_change_streamon(inst, V4L2_BUF_TYPE_VIDEO_CAPTURE= _MPLANE); - if (ret) - return ret; - - inst->last_buffer_dequeued =3D false; - - return iris_inst_change_sub_state(inst, clear_sub_state, 0); + return iris_process_streamon_input(inst); } =20 int iris_vdec_streamon_output(struct iris_inst *inst) @@ -543,7 +361,7 @@ int iris_vdec_streamon_output(struct iris_inst *inst) if (ret) return ret; =20 - ret =3D iris_vdec_process_streamon_output(inst); + ret =3D iris_process_streamon_output(inst); if (ret) goto error; =20 @@ -554,7 +372,7 @@ int iris_vdec_streamon_output(struct iris_inst *inst) return ret; =20 error: - iris_vdec_session_streamoff(inst, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); + iris_session_streamoff(inst, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); =20 return ret; } diff --git a/drivers/media/platform/qcom/iris/iris_vdec.h b/drivers/media/p= latform/qcom/iris/iris_vdec.h index 097e02bfa72b5ac4e46e66c61842df1d9dd4565b..ec1ce55d1375fd6518983baae2a= cf0fc43b6cabd 100644 --- a/drivers/media/platform/qcom/iris/iris_vdec.h +++ b/drivers/media/platform/qcom/iris/iris_vdec.h @@ -21,6 +21,5 @@ int iris_vdec_streamon_output(struct iris_inst *inst); int iris_vdec_qbuf(struct iris_inst *inst, struct vb2_v4l2_buffer *vbuf); int iris_vdec_start_cmd(struct iris_inst *inst); int iris_vdec_stop_cmd(struct iris_inst *inst); -int iris_vdec_session_streamoff(struct iris_inst *inst, u32 plane); =20 #endif diff --git a/drivers/media/platform/qcom/iris/iris_venc.c b/drivers/media/p= latform/qcom/iris/iris_venc.c index 4630ba12349a62a37515e93ed5efa2df197bce17..4b0da51e0477ab00019396242be= 9fd585c11ded3 100644 --- a/drivers/media/platform/qcom/iris/iris_venc.c +++ b/drivers/media/platform/qcom/iris/iris_venc.c @@ -7,6 +7,7 @@ #include =20 #include "iris_buffer.h" +#include "iris_common.h" #include "iris_ctrls.h" #include "iris_instance.h" #include "iris_venc.h" @@ -425,3 +426,34 @@ int iris_venc_g_param(struct iris_inst *inst, struct v= 4l2_streamparm *s_parm) =20 return 0; } + +int iris_venc_streamon_input(struct iris_inst *inst) +{ + int ret; + + ret =3D iris_set_properties(inst, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); + if (ret) + return ret; + + return iris_process_streamon_input(inst); +} + +int iris_venc_streamon_output(struct iris_inst *inst) +{ + int ret; + + ret =3D iris_set_properties(inst, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); + if (ret) + goto error; + + ret =3D iris_process_streamon_output(inst); + if (ret) + goto error; + + return ret; + +error: + iris_session_streamoff(inst, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); + + return ret; +} diff --git a/drivers/media/platform/qcom/iris/iris_venc.h b/drivers/media/p= latform/qcom/iris/iris_venc.h index 0d566b7fc89b96b8fbc62a35b2ba795ca0bcf460..941b5c186e4550e3eb6325d5ae3= eeac4fcee4675 100644 --- a/drivers/media/platform/qcom/iris/iris_venc.h +++ b/drivers/media/platform/qcom/iris/iris_venc.h @@ -18,5 +18,7 @@ int iris_venc_subscribe_event(struct iris_inst *inst, con= st struct v4l2_event_su int iris_venc_s_selection(struct iris_inst *inst, struct v4l2_selection *s= ); int iris_venc_g_param(struct iris_inst *inst, struct v4l2_streamparm *s_pa= rm); int iris_venc_s_param(struct iris_inst *inst, struct v4l2_streamparm *s_pa= rm); +int iris_venc_streamon_input(struct iris_inst *inst); +int iris_venc_streamon_output(struct iris_inst *inst); =20 #endif diff --git a/drivers/media/platform/qcom/iris/iris_vidc.c b/drivers/media/p= latform/qcom/iris/iris_vidc.c index 4c11cdac19f97d08a9e6242eea74649aad0242cf..be8688140fd22ffd02e8c286bfc= 5f62e050ceb5b 100644 --- a/drivers/media/platform/qcom/iris/iris_vidc.c +++ b/drivers/media/platform/qcom/iris/iris_vidc.c @@ -658,6 +658,8 @@ static const struct v4l2_ioctl_ops iris_v4l2_ioctl_ops_= enc =3D { .vidioc_s_selection =3D iris_s_selection, .vidioc_s_parm =3D iris_s_parm, .vidioc_g_parm =3D iris_g_parm, + .vidioc_streamon =3D v4l2_m2m_ioctl_streamon, + .vidioc_streamoff =3D v4l2_m2m_ioctl_streamoff, }; =20 void iris_init_ops(struct iris_core *core) --=20 2.34.1 From nobody Tue Oct 7 22:51:46 2025 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (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 A315D2EF9C0; Fri, 4 Jul 2025 07:54:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615699; cv=none; b=J95JDHuJQP7xIA7RW31L69dp1vCul5odqaIfKXXyz9mpGHBWqOPYZeiaPjWKgnke2ZL/61/zlnnicXdS84abV0R+a7QcPrFH1JGoWS/KhqVf9G7IQJVehUoEV1DUU1p1xp6lzC4kej1g64IgUyiG9cNzcw+Q4TkEZee0q8Z3fAY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615699; c=relaxed/simple; bh=yt78twjOxPyZbieKiQQQU/NnoiWl6RPUhKn4rxAT7dg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=ISlpTcFZ79iBY/LpUqY3XxehVg1hZ2JIgQV97TdXLum7NBG2Ae593Px1OItbWf9cTVhsw0p1f3V755hCHUAXzCfEcgaUVSzjBFP/xgMW5MRFNK1Hz5LTwBgATaP0Q2mN5j8FOwkqS1YhptI2Ga7hj/8X8GC7jeZT5SeSM72p3A8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=mGYzBVyA; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="mGYzBVyA" Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 563Ik5Iw005534; Fri, 4 Jul 2025 07:54:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= j8VP0uY6ce7iO6Gli1yCrQl3pDIoNzbV4UbyrGt6k1A=; b=mGYzBVyA8fdyJzMz tCr3p3MFrQVWFcfhgXSP7T1uIdjpLl/6nzXYn7d5Fz7j3OrMyYyIdZ9rf/Z0EZLf Vt2OF4puKcNfs5eg/tMG6aWvQZwh/2B7F0npgx9QrFiC2kxVDrj7LQxC5Sy3X3f5 UtidVWN2YoCT0+/flX/6oZXYLQpV16Z9gWrNEj/6Z/kXjvL978IgzfNCnNxBwYTd TajZ81xYtscKcvS3JZQWLiJSqkrUGLkFOJ7wZVmpwGjR2m0TkgwFE+5tbojyJ4ak s1C23yjV2yIlLKvC6MvdJei1N6RZtSSJVs2BC+GwpXzloIatfUgjwCe8Wu46uQAD Lz6YoQ== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 47j7qmjtu7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Jul 2025 07:54:39 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA05.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 5647scYs026045 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 4 Jul 2025 07:54:38 GMT Received: from hu-dikshita-hyd.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Fri, 4 Jul 2025 00:54:34 -0700 From: Dikshita Agarwal Date: Fri, 4 Jul 2025 13:23:22 +0530 Subject: [PATCH 22/25] media: iris: Set platform capabilities to firmware for encoder video device Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20250704-iris-video-encoder-v1-22-b6ce24e273cf@quicinc.com> References: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> In-Reply-To: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> To: Vikash Garodia , Abhinav Kumar , Bryan O'Donoghue , Mauro Carvalho Chehab , Hans Verkuil , Stefan Schmidt , "Vedang Nagar" CC: , , , Dikshita Agarwal X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1751615599; l=47077; i=quic_dikshita@quicinc.com; s=20240917; h=from:subject:message-id; bh=yt78twjOxPyZbieKiQQQU/NnoiWl6RPUhKn4rxAT7dg=; b=uIhAI1EReF4J5yQHUAyzFjNvZsxYxMZcQLhRzhwEmfW8HDhRjwvJ3jWM6uV6WHJqW9EWclUcM Y2tKLHFX+X3AbUQ5zXTvHt7QZyHLnSCBnxKge4Wndc6wyvEmIVXUPD5 X-Developer-Key: i=quic_dikshita@quicinc.com; a=ed25519; pk=EEvKY6Ar1OI5SWf44FJ1Ebo1KuQEVbbf5UNPO+UHVhM= X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Authority-Analysis: v=2.4 cv=C4TpyRP+ c=1 sm=1 tr=0 ts=686788bf cx=c_pps a=JYp8KDb2vCoCEuGobkYCKw==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=GEpy-HfZoHoA:10 a=IkcTkHD0fZMA:10 a=Wb1JkmetP80A:10 a=COk6AnOGAAAA:8 a=T8pL2teHXzhsmah6oQwA:9 a=QEXdDO2ut3YA:10 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-ORIG-GUID: iJZwvNFO6MiW1fJBMrH-3cBKKeNs1yiW X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzA0MDA2MCBTYWx0ZWRfX3ql3y2Ran7Ct HZZJi27axhZoArKUxFsTeDIo5XeTdpaLI6RQagcF7iRhJ7oSJXH2BUfQg/exOUl+Y0dteyYR2SX 9vnoNZWoffgLAcZreq0mnl4arZR9JiSUw98qC2jk24d6LZTrm4/CeC85aPJ+noW339VWY+x8ErG XE5QsJ3y2YcBW1MtDy9zN62iaKfpaInAAs2ORRqlnO/yYQNtk6U6E2HZJ4Yj1prBAWtuGInuzDB A0IFG2seExkClbu8sWQlLTHxHorjmTsh7xSJvcY1B8qQPDAVCXExt33wM26y+cwAKhFchqDa8Oe D6+VTHvpLteyA09Dwc6MbIsS6lUM9c6fTSLSM4mreCyDhZ76h10ocUvRH6/qeYXiCRB+3EpM+rD gvhEIokcS7jEdUlvlYTuhAVWd2IUBo2lqdgLdDV1saMwgQIGvK1NtVqZ0H0H+AjClMxs3V3g X-Proofpoint-GUID: iJZwvNFO6MiW1fJBMrH-3cBKKeNs1yiW X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-04_03,2025-07-02_04,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 phishscore=0 suspectscore=0 bulkscore=0 lowpriorityscore=0 clxscore=1015 priorityscore=1501 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507040060 Initialize and configure platform-specific capabilities for the encoder in the firmware during stream-on, to tailor encoding behavior to the current session's requirements. Some of these capabilities can also be updated dynamically when V4L2 controls are modified by the client after stream-on. Signed-off-by: Dikshita Agarwal Tested-by: Vikash Garodia # X1E80100 --- drivers/media/platform/qcom/iris/iris_buffer.c | 8 + drivers/media/platform/qcom/iris/iris_ctrls.c | 500 +++++++++++++++++= +++- drivers/media/platform/qcom/iris/iris_ctrls.h | 15 + .../platform/qcom/iris/iris_hfi_gen1_command.c | 117 +++++ .../platform/qcom/iris/iris_hfi_gen1_defines.h | 47 +- .../platform/qcom/iris/iris_hfi_gen1_response.c | 8 +- .../platform/qcom/iris/iris_hfi_gen2_defines.h | 32 +- .../platform/qcom/iris/iris_hfi_gen2_response.c | 9 +- drivers/media/platform/qcom/iris/iris_instance.h | 3 +- .../media/platform/qcom/iris/iris_platform_gen2.c | 21 + .../platform/qcom/iris/iris_platform_sm8250.c | 15 + 11 files changed, 745 insertions(+), 30 deletions(-) diff --git a/drivers/media/platform/qcom/iris/iris_buffer.c b/drivers/media= /platform/qcom/iris/iris_buffer.c index f9036057779830624eafe83e8c906a05ec3b3210..8ec10e6058f2b66c923a9925048= f90537603004b 100644 --- a/drivers/media/platform/qcom/iris/iris_buffer.c +++ b/drivers/media/platform/qcom/iris/iris_buffer.c @@ -227,10 +227,14 @@ static u32 iris_dec_bitstream_buffer_size(struct iris= _inst *inst) static u32 iris_enc_bitstream_buffer_size(struct iris_inst *inst) { u32 aligned_width, aligned_height, bitstream_size, yuv_size; + int bitrate_mode, frame_rc; struct v4l2_format *f; =20 f =3D inst->fmt_dst; =20 + bitrate_mode =3D inst->fw_caps[BITRATE_MODE].value; + frame_rc =3D inst->fw_caps[FRAME_RC_ENABLE].value; + aligned_width =3D ALIGN(f->fmt.pix_mp.width, 32); aligned_height =3D ALIGN(f->fmt.pix_mp.height, 32); bitstream_size =3D aligned_width * aligned_height * 3; @@ -242,6 +246,10 @@ static u32 iris_enc_bitstream_buffer_size(struct iris_= inst *inst) /* bitstream_size =3D 0.5 * yuv_size; */ bitstream_size =3D (bitstream_size >> 2); =20 + if ((!frame_rc || bitrate_mode =3D=3D V4L2_MPEG_VIDEO_BITRATE_MODE_CQ) && + bitstream_size < yuv_size) + bitstream_size =3D (bitstream_size << 1); + return ALIGN(bitstream_size, 4096); } =20 diff --git a/drivers/media/platform/qcom/iris/iris_ctrls.c b/drivers/media/= platform/qcom/iris/iris_ctrls.c index 797386cb96ab1d24be6cc1819e2f9202ab4cc224..754a5ad718bc37630bb86101230= 1df7a2e7342a1 100644 --- a/drivers/media/platform/qcom/iris/iris_ctrls.c +++ b/drivers/media/platform/qcom/iris/iris_ctrls.c @@ -7,8 +7,13 @@ #include =20 #include "iris_ctrls.h" +#include "iris_hfi_gen1_defines.h" +#include "iris_hfi_gen2_defines.h" #include "iris_instance.h" =20 +#define CABAC_MAX_BITRATE 160000000 +#define CAVLC_MAX_BITRATE 220000000 + static inline bool iris_valid_cap_id(enum platform_inst_fw_cap_type cap_id) { return cap_id >=3D 1 && cap_id < INST_FW_CAP_MAX; @@ -185,7 +190,7 @@ static u32 iris_get_v4l2_id(enum platform_inst_fw_cap_t= ype cap_id) } } =20 -static int iris_vdec_op_s_ctrl(struct v4l2_ctrl *ctrl) +static int iris_op_s_ctrl(struct v4l2_ctrl *ctrl) { struct iris_inst *inst =3D container_of(ctrl->handler, struct iris_inst, = ctrl_handler); enum platform_inst_fw_cap_type cap_id; @@ -206,11 +211,16 @@ static int iris_vdec_op_s_ctrl(struct v4l2_ctrl *ctrl) =20 inst->fw_caps[cap_id].value =3D ctrl->val; =20 + if (vb2_is_streaming(q)) { + if (cap[cap_id].set) + cap[cap_id].set(inst, cap_id); + } + return 0; } =20 static const struct v4l2_ctrl_ops iris_ctrl_ops =3D { - .s_ctrl =3D iris_vdec_op_s_ctrl, + .s_ctrl =3D iris_op_s_ctrl, }; =20 int iris_ctrls_init(struct iris_inst *inst) @@ -327,16 +337,24 @@ void iris_session_init_caps(struct iris_core *core) core->inst_fw_caps_enc[cap_id].value =3D caps[i].value; core->inst_fw_caps_enc[cap_id].flags =3D caps[i].flags; core->inst_fw_caps_enc[cap_id].hfi_id =3D caps[i].hfi_id; + core->inst_fw_caps_enc[cap_id].set =3D caps[i].set; } } =20 static u32 iris_get_port_info(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id) { - if (inst->fw_caps[cap_id].flags & CAP_FLAG_INPUT_PORT) - return HFI_PORT_BITSTREAM; - else if (inst->fw_caps[cap_id].flags & CAP_FLAG_OUTPUT_PORT) - return HFI_PORT_RAW; + if (inst->domain =3D=3D DECODER) { + if (inst->fw_caps[cap_id].flags & CAP_FLAG_INPUT_PORT) + return HFI_PORT_BITSTREAM; + else if (inst->fw_caps[cap_id].flags & CAP_FLAG_OUTPUT_PORT) + return HFI_PORT_RAW; + } else { + if (inst->fw_caps[cap_id].flags & CAP_FLAG_INPUT_PORT) + return HFI_PORT_RAW; + else if (inst->fw_caps[cap_id].flags & CAP_FLAG_OUTPUT_PORT) + return HFI_PORT_BITSTREAM; + } =20 return HFI_PORT_NONE; } @@ -376,8 +394,10 @@ int iris_set_stage(struct iris_inst *inst, enum platfo= rm_inst_fw_cap_type cap_id u32 width =3D inp_f->fmt.pix_mp.width; u32 work_mode =3D STAGE_2; =20 - if (iris_res_is_less_than(width, height, 1280, 720)) - work_mode =3D STAGE_1; + if (inst->domain =3D=3D DECODER) { + if (iris_res_is_less_than(width, height, 1280, 720)) + work_mode =3D STAGE_1; + } =20 return hfi_ops->session_set_property(inst, hfi_id, HFI_HOST_FLAGS_NONE, @@ -399,6 +419,470 @@ int iris_set_pipe(struct iris_inst *inst, enum platfo= rm_inst_fw_cap_type cap_id) &work_route, sizeof(u32)); } =20 +int iris_set_profile(struct iris_inst *inst, enum platform_inst_fw_cap_typ= e cap_id) +{ + const struct iris_hfi_command_ops *hfi_ops =3D inst->core->hfi_ops; + u32 hfi_id, hfi_value; + + if (inst->codec =3D=3D V4L2_PIX_FMT_H264) { + hfi_id =3D inst->fw_caps[PROFILE_H264].hfi_id; + hfi_value =3D inst->fw_caps[PROFILE_H264].value; + } else { + hfi_id =3D inst->fw_caps[PROFILE_HEVC].hfi_id; + hfi_value =3D inst->fw_caps[PROFILE_HEVC].value; + } + + return hfi_ops->session_set_property(inst, hfi_id, + HFI_HOST_FLAGS_NONE, + iris_get_port_info(inst, cap_id), + HFI_PAYLOAD_U32_ENUM, + &hfi_value, sizeof(u32)); +} + +int iris_set_level(struct iris_inst *inst, enum platform_inst_fw_cap_type = cap_id) +{ + const struct iris_hfi_command_ops *hfi_ops =3D inst->core->hfi_ops; + u32 hfi_id, hfi_value; + + if (inst->codec =3D=3D V4L2_PIX_FMT_H264) { + hfi_id =3D inst->fw_caps[LEVEL_H264].hfi_id; + hfi_value =3D inst->fw_caps[LEVEL_H264].value; + } else { + hfi_id =3D inst->fw_caps[LEVEL_HEVC].hfi_id; + hfi_value =3D inst->fw_caps[LEVEL_HEVC].value; + } + + return hfi_ops->session_set_property(inst, hfi_id, + HFI_HOST_FLAGS_NONE, + iris_get_port_info(inst, cap_id), + HFI_PAYLOAD_U32_ENUM, + &hfi_value, sizeof(u32)); +} + +int iris_set_profile_level_gen1(struct iris_inst *inst, enum platform_inst= _fw_cap_type cap_id) +{ + const struct iris_hfi_command_ops *hfi_ops =3D inst->core->hfi_ops; + u32 hfi_id =3D inst->fw_caps[cap_id].hfi_id; + struct hfi_profile_level pl; + + if (inst->codec =3D=3D V4L2_PIX_FMT_H264) { + pl.profile =3D inst->fw_caps[PROFILE_H264].value; + pl.level =3D inst->fw_caps[LEVEL_H264].value; + } else { + pl.profile =3D inst->fw_caps[PROFILE_HEVC].value; + pl.level =3D inst->fw_caps[LEVEL_HEVC].value; + } + + return hfi_ops->session_set_property(inst, hfi_id, + HFI_HOST_FLAGS_NONE, + iris_get_port_info(inst, cap_id), + HFI_PAYLOAD_U32_ENUM, + &pl, sizeof(u32)); +} + +int iris_set_header_mode_gen1(struct iris_inst *inst, enum platform_inst_f= w_cap_type cap_id) +{ + const struct iris_hfi_command_ops *hfi_ops =3D inst->core->hfi_ops; + u32 header_mode =3D inst->fw_caps[cap_id].value; + u32 hfi_id =3D inst->fw_caps[cap_id].hfi_id; + u32 hfi_val; + + if (header_mode =3D=3D V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE) + hfi_val =3D 0; + else + hfi_val =3D 1; + + return hfi_ops->session_set_property(inst, hfi_id, + HFI_HOST_FLAGS_NONE, + iris_get_port_info(inst, cap_id), + HFI_PAYLOAD_U32, + &hfi_val, sizeof(u32)); +} + +int iris_set_header_mode_gen2(struct iris_inst *inst, enum platform_inst_f= w_cap_type cap_id) +{ + const struct iris_hfi_command_ops *hfi_ops =3D inst->core->hfi_ops; + u32 prepend_sps_pps =3D inst->fw_caps[PREPEND_SPSPPS_TO_IDR].value; + u32 header_mode =3D inst->fw_caps[cap_id].value; + u32 hfi_id =3D inst->fw_caps[cap_id].hfi_id; + u32 hfi_val; + + if (prepend_sps_pps) + hfi_val =3D HFI_SEQ_HEADER_PREFIX_WITH_SYNC_FRAME; + else if (header_mode =3D=3D V4L2_MPEG_VIDEO_HEADER_MODE_JOINED_WITH_1ST_F= RAME) + hfi_val =3D HFI_SEQ_HEADER_JOINED_WITH_1ST_FRAME; + else + hfi_val =3D HFI_SEQ_HEADER_SEPERATE_FRAME; + + return hfi_ops->session_set_property(inst, hfi_id, + HFI_HOST_FLAGS_NONE, + iris_get_port_info(inst, cap_id), + HFI_PAYLOAD_U32_ENUM, + &hfi_val, sizeof(u32)); +} + +int iris_set_bitrate(struct iris_inst *inst, enum platform_inst_fw_cap_typ= e cap_id) +{ + const struct iris_hfi_command_ops *hfi_ops =3D inst->core->hfi_ops; + u32 entropy_mode =3D inst->fw_caps[ENTROPY_MODE].value; + u32 bitrate =3D inst->fw_caps[cap_id].value; + u32 hfi_id =3D inst->fw_caps[cap_id].hfi_id; + u32 max_bitrate; + + if (inst->codec =3D=3D V4L2_PIX_FMT_HEVC) + max_bitrate =3D CABAC_MAX_BITRATE; + + if (entropy_mode =3D=3D V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CABAC) + max_bitrate =3D CABAC_MAX_BITRATE; + else + max_bitrate =3D CAVLC_MAX_BITRATE; + + bitrate =3D min(bitrate, max_bitrate); + + return hfi_ops->session_set_property(inst, hfi_id, + HFI_HOST_FLAGS_NONE, + iris_get_port_info(inst, cap_id), + HFI_PAYLOAD_U32, + &bitrate, sizeof(u32)); +} + +int iris_set_peak_bitrate(struct iris_inst *inst, enum platform_inst_fw_ca= p_type cap_id) +{ + const struct iris_hfi_command_ops *hfi_ops =3D inst->core->hfi_ops; + u32 rc_mode =3D inst->fw_caps[BITRATE_MODE].value; + u32 peak_bitrate =3D inst->fw_caps[cap_id].value; + u32 bitrate =3D inst->fw_caps[BITRATE].value; + u32 hfi_id =3D inst->fw_caps[cap_id].hfi_id; + + if (rc_mode !=3D V4L2_MPEG_VIDEO_BITRATE_MODE_CBR) + return 0; + + if (inst->fw_caps[cap_id].flags & CAP_FLAG_CLIENT_SET) { + if (peak_bitrate < bitrate) + peak_bitrate =3D bitrate; + } else { + peak_bitrate =3D bitrate; + } + + inst->fw_caps[cap_id].value =3D peak_bitrate; + + return hfi_ops->session_set_property(inst, hfi_id, + HFI_HOST_FLAGS_NONE, + iris_get_port_info(inst, cap_id), + HFI_PAYLOAD_U32, + &peak_bitrate, sizeof(u32)); +} + +int iris_set_bitrate_mode_gen1(struct iris_inst *inst, enum platform_inst_= fw_cap_type cap_id) +{ + const struct iris_hfi_command_ops *hfi_ops =3D inst->core->hfi_ops; + u32 bitrate_mode =3D inst->fw_caps[BITRATE_MODE].value; + u32 frame_rc =3D inst->fw_caps[FRAME_RC_ENABLE].value; + u32 frame_skip =3D inst->fw_caps[FRAME_SKIP_MODE].value; + u32 hfi_id =3D inst->fw_caps[cap_id].hfi_id; + u32 rc_mode =3D 0; + + if (!frame_rc) + rc_mode =3D HFI_RATE_CONTROL_OFF; + else if (bitrate_mode =3D=3D V4L2_MPEG_VIDEO_BITRATE_MODE_VBR) + rc_mode =3D frame_skip ? HFI_RATE_CONTROL_VBR_VFR : HFI_RATE_CONTROL_VBR= _CFR; + else if (bitrate_mode =3D=3D V4L2_MPEG_VIDEO_BITRATE_MODE_CBR) + rc_mode =3D frame_skip ? HFI_RATE_CONTROL_CBR_VFR : HFI_RATE_CONTROL_CBR= _CFR; + else if (bitrate_mode =3D=3D V4L2_MPEG_VIDEO_BITRATE_MODE_CQ) + rc_mode =3D HFI_RATE_CONTROL_CQ; + + inst->hfi_rc_type =3D rc_mode; + + return hfi_ops->session_set_property(inst, hfi_id, + HFI_HOST_FLAGS_NONE, + iris_get_port_info(inst, cap_id), + HFI_PAYLOAD_U32_ENUM, + &rc_mode, sizeof(u32)); +} + +int iris_set_bitrate_mode_gen2(struct iris_inst *inst, enum platform_inst_= fw_cap_type cap_id) +{ + const struct iris_hfi_command_ops *hfi_ops =3D inst->core->hfi_ops; + u32 bitrate_mode =3D inst->fw_caps[BITRATE_MODE].value; + u32 frame_rc =3D inst->fw_caps[FRAME_RC_ENABLE].value; + u32 frame_skip =3D inst->fw_caps[FRAME_SKIP_MODE].value; + u32 hfi_id =3D inst->fw_caps[cap_id].hfi_id; + u32 rc_mode =3D 0; + + if (!frame_rc) + rc_mode =3D HFI_RC_OFF; + else if (bitrate_mode =3D=3D V4L2_MPEG_VIDEO_BITRATE_MODE_VBR) + rc_mode =3D HFI_RC_VBR_CFR; + else if (bitrate_mode =3D=3D V4L2_MPEG_VIDEO_BITRATE_MODE_CBR) + rc_mode =3D frame_skip ? HFI_RC_CBR_VFR : HFI_RC_CBR_CFR; + else if (bitrate_mode =3D=3D V4L2_MPEG_VIDEO_BITRATE_MODE_CQ) + rc_mode =3D HFI_RC_CQ; + + inst->hfi_rc_type =3D rc_mode; + + return hfi_ops->session_set_property(inst, hfi_id, + HFI_HOST_FLAGS_NONE, + iris_get_port_info(inst, cap_id), + HFI_PAYLOAD_U32_ENUM, + &rc_mode, sizeof(u32)); +} + +int iris_set_entropy_mode_gen1(struct iris_inst *inst, enum platform_inst_= fw_cap_type cap_id) +{ + const struct iris_hfi_command_ops *hfi_ops =3D inst->core->hfi_ops; + u32 entropy_mode =3D inst->fw_caps[cap_id].value; + u32 hfi_id =3D inst->fw_caps[cap_id].hfi_id; + u32 hfi_val; + + if (inst->codec !=3D V4L2_PIX_FMT_H264) + return 0; + + hfi_val =3D (entropy_mode =3D=3D V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CAVLC)= ? + HFI_H264_ENTROPY_CAVLC : HFI_H264_ENTROPY_CABAC; + + return hfi_ops->session_set_property(inst, hfi_id, + HFI_HOST_FLAGS_NONE, + iris_get_port_info(inst, cap_id), + HFI_PAYLOAD_U32, + &hfi_val, sizeof(u32)); +} + +int iris_set_entropy_mode_gen2(struct iris_inst *inst, enum platform_inst_= fw_cap_type cap_id) +{ + const struct iris_hfi_command_ops *hfi_ops =3D inst->core->hfi_ops; + u32 entropy_mode =3D inst->fw_caps[cap_id].value; + u32 hfi_id =3D inst->fw_caps[cap_id].hfi_id; + u32 profile; + + if (inst->codec !=3D V4L2_PIX_FMT_H264) + return 0; + + profile =3D inst->fw_caps[PROFILE_H264].value; + + if (profile =3D=3D V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE || + profile =3D=3D V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_BASELINE) + entropy_mode =3D V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CAVLC; + + inst->fw_caps[cap_id].value =3D entropy_mode; + + return hfi_ops->session_set_property(inst, hfi_id, + HFI_HOST_FLAGS_NONE, + iris_get_port_info(inst, cap_id), + HFI_PAYLOAD_U32, + &entropy_mode, sizeof(u32)); +} + +int iris_set_min_qp(struct iris_inst *inst, enum platform_inst_fw_cap_type= cap_id) +{ + const struct iris_hfi_command_ops *hfi_ops =3D inst->core->hfi_ops; + u32 i_qp_enable =3D 0, p_qp_enable =3D 0, b_qp_enable =3D 0; + u32 i_frame_qp =3D 0, p_frame_qp =3D 0, b_frame_qp =3D 0; + u32 min_qp_enable =3D 0, client_qp_enable =3D 0; + u32 hfi_id =3D inst->fw_caps[cap_id].hfi_id; + u32 hfi_val; + + if (inst->codec =3D=3D V4L2_PIX_FMT_H264) { + if (inst->fw_caps[MIN_FRAME_QP_H264].flags & CAP_FLAG_CLIENT_SET) + min_qp_enable =3D 1; + if (min_qp_enable || + (inst->fw_caps[I_FRAME_MIN_QP_H264].flags & CAP_FLAG_CLIENT_SET)) + i_qp_enable =3D 1; + if (min_qp_enable || + (inst->fw_caps[P_FRAME_MIN_QP_H264].flags & CAP_FLAG_CLIENT_SET)) + p_qp_enable =3D 1; + if (min_qp_enable || + (inst->fw_caps[B_FRAME_MIN_QP_H264].flags & CAP_FLAG_CLIENT_SET)) + b_qp_enable =3D 1; + } else { + if (inst->fw_caps[MIN_FRAME_QP_HEVC].flags & CAP_FLAG_CLIENT_SET) + min_qp_enable =3D 1; + if (min_qp_enable || + (inst->fw_caps[I_FRAME_MIN_QP_HEVC].flags & CAP_FLAG_CLIENT_SET)) + i_qp_enable =3D 1; + if (min_qp_enable || + (inst->fw_caps[P_FRAME_MIN_QP_HEVC].flags & CAP_FLAG_CLIENT_SET)) + p_qp_enable =3D 1; + if (min_qp_enable || + (inst->fw_caps[B_FRAME_MIN_QP_HEVC].flags & CAP_FLAG_CLIENT_SET)) + b_qp_enable =3D 1; + } + + client_qp_enable =3D i_qp_enable | p_qp_enable << 1 | b_qp_enable << 2; + if (!client_qp_enable) + return 0; + + if (inst->codec =3D=3D V4L2_PIX_FMT_H264) { + i_frame_qp =3D max(inst->fw_caps[I_FRAME_MIN_QP_H264].value, + inst->fw_caps[MIN_FRAME_QP_H264].value); + p_frame_qp =3D max(inst->fw_caps[P_FRAME_MIN_QP_H264].value, + inst->fw_caps[MIN_FRAME_QP_H264].value); + b_frame_qp =3D max(inst->fw_caps[B_FRAME_MIN_QP_H264].value, + inst->fw_caps[MIN_FRAME_QP_H264].value); + } else { + i_frame_qp =3D max(inst->fw_caps[I_FRAME_MIN_QP_HEVC].value, + inst->fw_caps[MIN_FRAME_QP_HEVC].value); + p_frame_qp =3D max(inst->fw_caps[P_FRAME_MIN_QP_HEVC].value, + inst->fw_caps[MIN_FRAME_QP_HEVC].value); + b_frame_qp =3D max(inst->fw_caps[B_FRAME_MIN_QP_HEVC].value, + inst->fw_caps[MIN_FRAME_QP_HEVC].value); + } + + hfi_val =3D i_frame_qp | p_frame_qp << 8 | b_frame_qp << 16 | client_qp_e= nable << 24; + + return hfi_ops->session_set_property(inst, hfi_id, + HFI_HOST_FLAGS_NONE, + iris_get_port_info(inst, cap_id), + HFI_PAYLOAD_32_PACKED, + &hfi_val, sizeof(u32)); +} + +int iris_set_max_qp(struct iris_inst *inst, enum platform_inst_fw_cap_type= cap_id) +{ + const struct iris_hfi_command_ops *hfi_ops =3D inst->core->hfi_ops; + u32 i_qp_enable =3D 0, p_qp_enable =3D 0, b_qp_enable =3D 0; + u32 max_qp_enable =3D 0, client_qp_enable; + u32 i_frame_qp, p_frame_qp, b_frame_qp; + u32 hfi_id =3D inst->fw_caps[cap_id].hfi_id; + u32 hfi_val; + + if (inst->codec =3D=3D V4L2_PIX_FMT_H264) { + if (inst->fw_caps[MAX_FRAME_QP_H264].flags & CAP_FLAG_CLIENT_SET) + max_qp_enable =3D 1; + if (max_qp_enable || + (inst->fw_caps[I_FRAME_MAX_QP_H264].flags & CAP_FLAG_CLIENT_SET)) + i_qp_enable =3D 1; + if (max_qp_enable || + (inst->fw_caps[P_FRAME_MAX_QP_H264].flags & CAP_FLAG_CLIENT_SET)) + p_qp_enable =3D 1; + if (max_qp_enable || + (inst->fw_caps[B_FRAME_MAX_QP_H264].flags & CAP_FLAG_CLIENT_SET)) + b_qp_enable =3D 1; + } else { + if (inst->fw_caps[MAX_FRAME_QP_HEVC].flags & CAP_FLAG_CLIENT_SET) + max_qp_enable =3D 1; + if (max_qp_enable || + (inst->fw_caps[I_FRAME_MAX_QP_HEVC].flags & CAP_FLAG_CLIENT_SET)) + i_qp_enable =3D 1; + if (max_qp_enable || + (inst->fw_caps[P_FRAME_MAX_QP_HEVC].flags & CAP_FLAG_CLIENT_SET)) + p_qp_enable =3D 1; + if (max_qp_enable || + (inst->fw_caps[B_FRAME_MAX_QP_HEVC].flags & CAP_FLAG_CLIENT_SET)) + b_qp_enable =3D 1; + } + + client_qp_enable =3D i_qp_enable | p_qp_enable << 1 | b_qp_enable << 2; + if (!client_qp_enable) + return 0; + + if (inst->codec =3D=3D V4L2_PIX_FMT_H264) { + i_frame_qp =3D min(inst->fw_caps[I_FRAME_MAX_QP_H264].value, + inst->fw_caps[MAX_FRAME_QP_H264].value); + p_frame_qp =3D min(inst->fw_caps[P_FRAME_MAX_QP_H264].value, + inst->fw_caps[MAX_FRAME_QP_H264].value); + b_frame_qp =3D min(inst->fw_caps[B_FRAME_MAX_QP_H264].value, + inst->fw_caps[MAX_FRAME_QP_H264].value); + } else { + i_frame_qp =3D min(inst->fw_caps[I_FRAME_MAX_QP_HEVC].value, + inst->fw_caps[MAX_FRAME_QP_HEVC].value); + p_frame_qp =3D min(inst->fw_caps[P_FRAME_MAX_QP_HEVC].value, + inst->fw_caps[MAX_FRAME_QP_HEVC].value); + b_frame_qp =3D min(inst->fw_caps[B_FRAME_MAX_QP_HEVC].value, + inst->fw_caps[MAX_FRAME_QP_HEVC].value); + } + + hfi_val =3D i_frame_qp | p_frame_qp << 8 | b_frame_qp << 16 | + client_qp_enable << 24; + + return hfi_ops->session_set_property(inst, hfi_id, + HFI_HOST_FLAGS_NONE, + iris_get_port_info(inst, cap_id), + HFI_PAYLOAD_32_PACKED, + &hfi_val, sizeof(u32)); +} + +int iris_set_frame_qp(struct iris_inst *inst, enum platform_inst_fw_cap_ty= pe cap_id) +{ + const struct iris_hfi_command_ops *hfi_ops =3D inst->core->hfi_ops; + u32 i_qp_enable =3D 0, p_qp_enable =3D 0, b_qp_enable =3D 0, client_qp_en= able; + u32 i_frame_qp, p_frame_qp, b_frame_qp; + u32 hfi_id =3D inst->fw_caps[cap_id].hfi_id; + struct vb2_queue *q; + u32 hfi_val; + + q =3D v4l2_m2m_get_dst_vq(inst->m2m_ctx); + if (vb2_is_streaming(q)) { + if (inst->hfi_rc_type !=3D HFI_RC_OFF) + return 0; + } + + if (inst->hfi_rc_type =3D=3D HFI_RC_OFF) { + i_qp_enable =3D 1; + p_qp_enable =3D 1; + b_qp_enable =3D 1; + } else { + if (inst->codec =3D=3D V4L2_PIX_FMT_H264) { + if (inst->fw_caps[I_FRAME_QP_H264].flags & CAP_FLAG_CLIENT_SET) + i_qp_enable =3D 1; + if (inst->fw_caps[P_FRAME_QP_H264].flags & CAP_FLAG_CLIENT_SET) + p_qp_enable =3D 1; + if (inst->fw_caps[B_FRAME_QP_H264].flags & CAP_FLAG_CLIENT_SET) + b_qp_enable =3D 1; + } else { + if (inst->fw_caps[I_FRAME_QP_HEVC].flags & CAP_FLAG_CLIENT_SET) + i_qp_enable =3D 1; + if (inst->fw_caps[P_FRAME_QP_HEVC].flags & CAP_FLAG_CLIENT_SET) + p_qp_enable =3D 1; + if (inst->fw_caps[B_FRAME_QP_HEVC].flags & CAP_FLAG_CLIENT_SET) + b_qp_enable =3D 1; + } + } + + client_qp_enable =3D i_qp_enable | p_qp_enable << 1 | b_qp_enable << 2; + if (!client_qp_enable) + return 0; + + if (inst->codec =3D=3D V4L2_PIX_FMT_H264) { + i_frame_qp =3D inst->fw_caps[I_FRAME_QP_H264].value; + p_frame_qp =3D inst->fw_caps[P_FRAME_QP_H264].value; + b_frame_qp =3D inst->fw_caps[B_FRAME_QP_H264].value; + } else { + i_frame_qp =3D inst->fw_caps[I_FRAME_QP_HEVC].value; + p_frame_qp =3D inst->fw_caps[P_FRAME_QP_HEVC].value; + b_frame_qp =3D inst->fw_caps[B_FRAME_QP_HEVC].value; + } + + hfi_val =3D i_frame_qp | p_frame_qp << 8 | b_frame_qp << 16 | + client_qp_enable << 24; + + return hfi_ops->session_set_property(inst, hfi_id, + HFI_HOST_FLAGS_NONE, + iris_get_port_info(inst, cap_id), + HFI_PAYLOAD_32_PACKED, + &hfi_val, sizeof(u32)); +} + +int iris_set_qp_range(struct iris_inst *inst, enum platform_inst_fw_cap_ty= pe cap_id) +{ + const struct iris_hfi_command_ops *hfi_ops =3D inst->core->hfi_ops; + struct hfi_quantization_range_v2 range; + u32 hfi_id =3D inst->fw_caps[cap_id].hfi_id; + + if (inst->codec =3D=3D V4L2_PIX_FMT_HEVC) { + range.min_qp.qp_packed =3D inst->fw_caps[MIN_FRAME_QP_HEVC].value; + range.max_qp.qp_packed =3D inst->fw_caps[MAX_FRAME_QP_HEVC].value; + } else { + range.min_qp.qp_packed =3D inst->fw_caps[MIN_FRAME_QP_H264].value; + range.max_qp.qp_packed =3D inst->fw_caps[MAX_FRAME_QP_H264].value; + } + + return hfi_ops->session_set_property(inst, hfi_id, + HFI_HOST_FLAGS_NONE, + iris_get_port_info(inst, cap_id), + HFI_PAYLOAD_32_PACKED, + &range, sizeof(range)); +} + int iris_set_properties(struct iris_inst *inst, u32 plane) { const struct iris_hfi_command_ops *hfi_ops =3D inst->core->hfi_ops; diff --git a/drivers/media/platform/qcom/iris/iris_ctrls.h b/drivers/media/= platform/qcom/iris/iris_ctrls.h index 9b5741868933b08dcefd4868ba89f3c43760d31c..30af333cc4941e737eb1ae83a69= 44b4192896e23 100644 --- a/drivers/media/platform/qcom/iris/iris_ctrls.h +++ b/drivers/media/platform/qcom/iris/iris_ctrls.h @@ -17,6 +17,21 @@ int iris_set_u32_enum(struct iris_inst *inst, enum platf= orm_inst_fw_cap_type cap int iris_set_stage(struct iris_inst *inst, enum platform_inst_fw_cap_type = cap_id); int iris_set_pipe(struct iris_inst *inst, enum platform_inst_fw_cap_type c= ap_id); int iris_set_u32(struct iris_inst *inst, enum platform_inst_fw_cap_type ca= p_id); +int iris_set_profile(struct iris_inst *inst, enum platform_inst_fw_cap_typ= e cap_id); +int iris_set_level(struct iris_inst *inst, enum platform_inst_fw_cap_type = cap_id); +int iris_set_profile_level_gen1(struct iris_inst *inst, enum platform_inst= _fw_cap_type cap_id); +int iris_set_header_mode_gen1(struct iris_inst *inst, enum platform_inst_f= w_cap_type cap_id); +int iris_set_header_mode_gen2(struct iris_inst *inst, enum platform_inst_f= w_cap_type cap_id); +int iris_set_bitrate(struct iris_inst *inst, enum platform_inst_fw_cap_typ= e cap_id); +int iris_set_peak_bitrate(struct iris_inst *inst, enum platform_inst_fw_ca= p_type cap_id); +int iris_set_bitrate_mode_gen1(struct iris_inst *inst, enum platform_inst_= fw_cap_type cap_id); +int iris_set_bitrate_mode_gen2(struct iris_inst *inst, enum platform_inst_= fw_cap_type cap_id); +int iris_set_entropy_mode_gen1(struct iris_inst *inst, enum platform_inst_= fw_cap_type cap_id); +int iris_set_entropy_mode_gen2(struct iris_inst *inst, enum platform_inst_= fw_cap_type cap_id); +int iris_set_min_qp(struct iris_inst *inst, enum platform_inst_fw_cap_type= cap_id); +int iris_set_max_qp(struct iris_inst *inst, enum platform_inst_fw_cap_type= cap_id); +int iris_set_frame_qp(struct iris_inst *inst, enum platform_inst_fw_cap_ty= pe cap_id); +int iris_set_qp_range(struct iris_inst *inst, enum platform_inst_fw_cap_ty= pe cap_id); int iris_set_properties(struct iris_inst *inst, u32 plane); =20 #endif diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c b/dri= vers/media/platform/qcom/iris/iris_hfi_gen1_command.c index fead3318743a09ecdc363eda4cbf252f640eb6e0..a575d618a341cceb5b062574669= 94544a5e61862 100644 --- a/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c @@ -539,6 +539,123 @@ iris_hfi_gen1_packet_session_set_property(struct hfi_= session_set_property_pkt *p packet->shdr.hdr.size +=3D sizeof(u32) + sizeof(*wm); break; } + case HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT: { + struct hfi_profile_level *in =3D pdata, *pl =3D prop_data; + + pl->level =3D in->level; + pl->profile =3D in->profile; + if (pl->profile <=3D 0) + /* Profile not supported, falling back to high */ + pl->profile =3D V4L2_MPEG_VIDEO_H264_PROFILE_HIGH; + + if (!pl->level) + /* Level not supported, falling back to 1 */ + pl->level =3D 1; + + packet->shdr.hdr.size +=3D sizeof(u32) + sizeof(*pl); + break; + } + case HFI_PROPERTY_CONFIG_VENC_SYNC_FRAME_SEQUENCE_HEADER: { + struct hfi_enable *en =3D prop_data; + u32 *in =3D pdata; + + en->enable =3D *in; + packet->shdr.hdr.size +=3D sizeof(u32) + sizeof(*en); + break; + } + case HFI_PROPERTY_CONFIG_VENC_TARGET_BITRATE: { + struct hfi_bitrate *brate =3D prop_data; + u32 *in =3D pdata; + + brate->bitrate =3D *in; + brate->layer_id =3D 0; + packet->shdr.hdr.size +=3D sizeof(u32) + sizeof(*brate); + break; + } + case HFI_PROPERTY_CONFIG_VENC_MAX_BITRATE: { + struct hfi_bitrate *brate =3D prop_data; + u32 *in =3D pdata; + + brate->bitrate =3D *in; + brate->layer_id =3D 0; + packet->shdr.hdr.size +=3D sizeof(u32) + sizeof(*brate); + break; + } + case HFI_PROPERTY_PARAM_VENC_RATE_CONTROL: { + u32 *in =3D pdata; + + switch (*in) { + case HFI_RATE_CONTROL_OFF: + case HFI_RATE_CONTROL_CBR_CFR: + case HFI_RATE_CONTROL_CBR_VFR: + case HFI_RATE_CONTROL_VBR_CFR: + case HFI_RATE_CONTROL_VBR_VFR: + case HFI_RATE_CONTROL_CQ: + break; + default: + return -EINVAL; + } + + packet->data[1] =3D *in; + packet->shdr.hdr.size +=3D sizeof(u32) * 2; + break; + } + case HFI_PROPERTY_PARAM_VENC_H264_ENTROPY_CONTROL: { + struct hfi_h264_entropy_control *entropy =3D prop_data; + u32 *in =3D pdata; + + entropy->entropy_mode =3D *in; + if (entropy->entropy_mode =3D=3D HFI_H264_ENTROPY_CABAC) + entropy->cabac_model =3D HFI_H264_CABAC_MODEL_0; + packet->shdr.hdr.size +=3D sizeof(u32) + sizeof(*entropy); + break; + } + case HFI_PROPERTY_PARAM_VENC_SESSION_QP_RANGE_V2: { + struct hfi_quantization_range_v2 *range =3D prop_data; + struct hfi_quantization_range_v2 *in =3D pdata; + u32 min_qp, max_qp; + + min_qp =3D in->min_qp.qp_packed; + max_qp =3D in->max_qp.qp_packed; + + /* We'll be packing in the qp, so make sure we + * won't be losing data when masking + */ + if (min_qp > 0xff || max_qp > 0xff) + return -ERANGE; + + range->min_qp.layer_id =3D 0xFF; + range->max_qp.layer_id =3D 0xFF; + range->min_qp.qp_packed =3D (min_qp & 0xFF) | ((min_qp & 0xFF) << 8) | + ((min_qp & 0xFF) << 16); + range->max_qp.qp_packed =3D (max_qp & 0xFF) | ((max_qp & 0xFF) << 8) | + ((max_qp & 0xFF) << 16); + range->min_qp.enable =3D 7; + range->max_qp.enable =3D 7; + packet->shdr.hdr.size +=3D sizeof(u32) + sizeof(*range); + break; + } + case HFI_PROPERTY_CONFIG_FRAME_RATE: { + struct hfi_framerate *frate =3D prop_data; + struct hfi_framerate *in =3D pdata; + + frate->buffer_type =3D in->buffer_type; + frate->framerate =3D in->framerate; + packet->shdr.hdr.size +=3D sizeof(u32) + sizeof(*frate); + break; + } + case HFI_PROPERTY_PARAM_UNCOMPRESSED_PLANE_ACTUAL_INFO: { + struct hfi_uncompressed_plane_actual_info *plane_actual_info =3D prop_da= ta; + struct hfi_uncompressed_plane_actual_info *in =3D pdata; + + plane_actual_info->buffer_type =3D in->buffer_type; + plane_actual_info->num_planes =3D in->num_planes; + plane_actual_info->plane_format[0] =3D in->plane_format[0]; + if (in->num_planes > 1) + plane_actual_info->plane_format[1] =3D in->plane_format[1]; + packet->shdr.hdr.size +=3D sizeof(u32) + sizeof(*plane_actual_info); + break; + } default: return -EINVAL; } diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen1_defines.h b/dri= vers/media/platform/qcom/iris/iris_hfi_gen1_defines.h index dd6521bc2dfeab652ded11698a88a9f850f01695..6ce166fb42c7ae4823f88d7303d= 651752018ea2d 100644 --- a/drivers/media/platform/qcom/iris/iris_hfi_gen1_defines.h +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen1_defines.h @@ -114,15 +114,25 @@ #define HFI_MSG_SESSION_RELEASE_RESOURCES 0x22100a #define HFI_MSG_SESSION_RELEASE_BUFFERS 0x22100c =20 -#define HFI_PICTURE_I 0x00000001 -#define HFI_PICTURE_P 0x00000002 -#define HFI_PICTURE_B 0x00000004 -#define HFI_PICTURE_IDR 0x00000008 +#define HFI_GEN1_PICTURE_I 0x00000001 +#define HFI_GEN1_PICTURE_P 0x00000002 +#define HFI_GEN1_PICTURE_B 0x00000004 +#define HFI_GEN1_PICTURE_IDR 0x00000008 #define HFI_FRAME_NOTCODED 0x7f002000 #define HFI_FRAME_YUV 0x7f004000 #define HFI_UNUSED_PICT 0x10000000 -#define HFI_BUFFERFLAG_DATACORRUPT 0x00000008 -#define HFI_BUFFERFLAG_DROP_FRAME 0x20000000 +#define HFI_BUFFERFLAG_DATACORRUPT 0x00000008 +#define HFI_BUFFERFLAG_DROP_FRAME 0x20000000 +#define HFI_RATE_CONTROL_OFF 0x1000001 +#define HFI_RATE_CONTROL_VBR_VFR 0x1000002 +#define HFI_RATE_CONTROL_VBR_CFR 0x1000003 +#define HFI_RATE_CONTROL_CBR_VFR 0x1000004 +#define HFI_RATE_CONTROL_CBR_CFR 0x1000005 +#define HFI_RATE_CONTROL_CQ 0x1000008 + +#define HFI_H264_ENTROPY_CAVLC 0x1 +#define HFI_H264_ENTROPY_CABAC 0x2 + #define HFI_PROPERTY_PARAM_VENC_H264_ENTROPY_CONTROL 0x2005002 #define HFI_PROPERTY_PARAM_VENC_H264_DEBLOCK_CONTROL 0x2005003 #define HFI_PROPERTY_PARAM_VENC_RATE_CONTROL 0x2005004 @@ -389,6 +399,31 @@ struct hfi_buffer_requirements { u32 alignment; }; =20 +struct hfi_bitrate { + u32 bitrate; + u32 layer_id; +}; + +#define HFI_H264_CABAC_MODEL_0 0x1 + +struct hfi_h264_entropy_control { + u32 entropy_mode; + u32 cabac_model; +}; + +struct hfi_quantization_v2 { + u32 qp_packed; + u32 layer_id; + u32 enable; + u32 reserved[3]; +}; + +struct hfi_quantization_range_v2 { + struct hfi_quantization_v2 min_qp; + struct hfi_quantization_v2 max_qp; + u32 reserved[4]; +}; + struct hfi_framerate { u32 buffer_type; u32 framerate; diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen1_response.c b/dr= ivers/media/platform/qcom/iris/iris_hfi_gen1_response.c index 2a96458833835422d30c9386d15cc1e4fb226e3d..82d3e8de7bff0ac53a971b4763a= e848ff8c61ff2 100644 --- a/drivers/media/platform/qcom/iris/iris_hfi_gen1_response.c +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen1_response.c @@ -469,14 +469,14 @@ static void iris_hfi_gen1_session_ftb_done(struct iri= s_inst *inst, void *packet) buf->timestamp =3D timestamp_us; =20 switch (pic_type) { - case HFI_PICTURE_IDR: - case HFI_PICTURE_I: + case HFI_GEN1_PICTURE_IDR: + case HFI_GEN1_PICTURE_I: flags |=3D V4L2_BUF_FLAG_KEYFRAME; break; - case HFI_PICTURE_P: + case HFI_GEN1_PICTURE_P: flags |=3D V4L2_BUF_FLAG_PFRAME; break; - case HFI_PICTURE_B: + case HFI_GEN1_PICTURE_B: flags |=3D V4L2_BUF_FLAG_BFRAME; break; case HFI_FRAME_NOTCODED: diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen2_defines.h b/dri= vers/media/platform/qcom/iris/iris_hfi_gen2_defines.h index b3d1c966958e516d940a7795e5cbe2f8e8bada57..aa1f795f5626c1f76a32dd65030= 2633877ce67be 100644 --- a/drivers/media/platform/qcom/iris/iris_hfi_gen2_defines.h +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen2_defines.h @@ -56,6 +56,16 @@ #define HFI_PROP_BUFFER_HOST_MAX_COUNT 0x03000123 #define HFI_PROP_BUFFER_FW_MIN_OUTPUT_COUNT 0x03000124 #define HFI_PROP_PIC_ORDER_CNT_TYPE 0x03000128 + +enum hfi_rate_control { + HFI_RC_VBR_CFR =3D 0x00000000, + HFI_RC_CBR_CFR =3D 0x00000001, + HFI_RC_CQ =3D 0x00000002, + HFI_RC_OFF =3D 0x00000003, + HFI_RC_CBR_VFR =3D 0x00000004, + HFI_RC_LOSSLESS =3D 0x00000005, +}; + #define HFI_PROP_RATE_CONTROL 0x0300012a #define HFI_PROP_QP_PACKED 0x0300012e #define HFI_PROP_MIN_QP_PACKED 0x0300012f @@ -64,6 +74,14 @@ #define HFI_PROP_MAX_GOP_FRAMES 0x03000146 #define HFI_PROP_MAX_B_FRAMES 0x03000147 #define HFI_PROP_QUALITY_MODE 0x03000148 + +enum hfi_seq_header_mode { + HFI_SEQ_HEADER_SEPERATE_FRAME =3D 0x00000001, + HFI_SEQ_HEADER_JOINED_WITH_1ST_FRAME =3D 0x00000002, + HFI_SEQ_HEADER_PREFIX_WITH_SYNC_FRAME =3D 0x00000004, + HFI_SEQ_HEADER_METADATA =3D 0x00000008, +}; + #define HFI_PROP_SEQ_HEADER_MODE 0x03000149 #define HFI_PROP_SIGNAL_COLOR_INFO 0x03000155 #define HFI_PROP_PICTURE_TYPE 0x03000162 @@ -123,13 +141,13 @@ enum hfi_codec_type { }; =20 enum hfi_picture_type { - HFI_PICTURE_IDR =3D 0x00000001, - HFI_PICTURE_P =3D 0x00000002, - HFI_PICTURE_B =3D 0x00000004, - HFI_PICTURE_I =3D 0x00000008, - HFI_PICTURE_CRA =3D 0x00000010, - HFI_PICTURE_BLA =3D 0x00000020, - HFI_PICTURE_NOSHOW =3D 0x00000040, + HFI_GEN2_PICTURE_IDR =3D 0x00000001, + HFI_GEN2_PICTURE_P =3D 0x00000002, + HFI_GEN2_PICTURE_B =3D 0x00000004, + HFI_GEN2_PICTURE_I =3D 0x00000008, + HFI_GEN2_PICTURE_CRA =3D 0x00000010, + HFI_GEN2_PICTURE_BLA =3D 0x00000020, + HFI_GEN2_PICTURE_NOSHOW =3D 0x00000040, }; =20 enum hfi_buffer_type { diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c b/dr= ivers/media/platform/qcom/iris/iris_hfi_gen2_response.c index dda775d463e916f70da0b879702d96df18ea8bf7..4e4fae2359ccf210186397a4170= 49208728b5d53 100644 --- a/drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c @@ -87,17 +87,18 @@ static bool iris_hfi_gen2_is_valid_hfi_port(u32 port, u= 32 buffer_type) =20 static int iris_hfi_gen2_get_driver_buffer_flags(struct iris_inst *inst, u= 32 hfi_flags) { - u32 keyframe =3D HFI_PICTURE_IDR | HFI_PICTURE_I | HFI_PICTURE_CRA | HFI_= PICTURE_BLA; struct iris_inst_hfi_gen2 *inst_hfi_gen2 =3D to_iris_inst_hfi_gen2(inst); + u32 keyframe =3D HFI_GEN2_PICTURE_IDR | HFI_GEN2_PICTURE_I | + HFI_GEN2_PICTURE_CRA | HFI_GEN2_PICTURE_BLA; u32 driver_flags =3D 0; =20 - if (inst_hfi_gen2->hfi_frame_info.picture_type & HFI_PICTURE_NOSHOW) + if (inst_hfi_gen2->hfi_frame_info.picture_type & HFI_GEN2_PICTURE_NOSHOW) driver_flags |=3D V4L2_BUF_FLAG_ERROR; else if (inst_hfi_gen2->hfi_frame_info.picture_type & keyframe) driver_flags |=3D V4L2_BUF_FLAG_KEYFRAME; - else if (inst_hfi_gen2->hfi_frame_info.picture_type & HFI_PICTURE_P) + else if (inst_hfi_gen2->hfi_frame_info.picture_type & HFI_GEN2_PICTURE_P) driver_flags |=3D V4L2_BUF_FLAG_PFRAME; - else if (inst_hfi_gen2->hfi_frame_info.picture_type & HFI_PICTURE_B) + else if (inst_hfi_gen2->hfi_frame_info.picture_type & HFI_GEN2_PICTURE_B) driver_flags |=3D V4L2_BUF_FLAG_BFRAME; =20 if (inst_hfi_gen2->hfi_frame_info.data_corrupt || inst_hfi_gen2->hfi_fram= e_info.overflow) diff --git a/drivers/media/platform/qcom/iris/iris_instance.h b/drivers/med= ia/platform/qcom/iris/iris_instance.h index b75549718df3c87cd85aecfc74c873c60cd4bde5..5982d7adefeab80905478b32cdd= ba7bd4651a691 100644 --- a/drivers/media/platform/qcom/iris/iris_instance.h +++ b/drivers/media/platform/qcom/iris/iris_instance.h @@ -63,7 +63,7 @@ struct iris_fmt { * @last_buffer_dequeued: a flag to indicate that last buffer is sent by d= river * @frame_rate: frame rate of current instance * @operating_rate: operating rate of current instance - + * @hfi_rc_type: rate control type */ =20 struct iris_inst { @@ -101,6 +101,7 @@ struct iris_inst { bool last_buffer_dequeued; u32 frame_rate; u32 operating_rate; + u32 hfi_rc_type; }; =20 #endif diff --git a/drivers/media/platform/qcom/iris/iris_platform_gen2.c b/driver= s/media/platform/qcom/iris/iris_platform_gen2.c index bfafd7c436116423bd3e8ecd4cf24038e383d2c8..8c0dd09c592df1c679e3e98590b= a1b430c6d21c9 100644 --- a/drivers/media/platform/qcom/iris/iris_platform_gen2.c +++ b/drivers/media/platform/qcom/iris/iris_platform_gen2.c @@ -213,6 +213,7 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8550_e= nc[] =3D { .value =3D V4L2_MPEG_VIDEO_H264_PROFILE_HIGH, .hfi_id =3D HFI_PROP_PROFILE, .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + .set =3D iris_set_profile, }, { .cap_id =3D PROFILE_HEVC, @@ -224,6 +225,7 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8550_e= nc[] =3D { .value =3D V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN, .hfi_id =3D HFI_PROP_PROFILE, .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + .set =3D iris_set_profile, }, { .cap_id =3D LEVEL_H264, @@ -250,6 +252,7 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8550_e= nc[] =3D { .value =3D V4L2_MPEG_VIDEO_H264_LEVEL_5_0, .hfi_id =3D HFI_PROP_LEVEL, .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + .set =3D iris_set_level, }, { .cap_id =3D LEVEL_HEVC, @@ -271,6 +274,7 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8550_e= nc[] =3D { .value =3D V4L2_MPEG_VIDEO_HEVC_LEVEL_5, .hfi_id =3D HFI_PROP_LEVEL, .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + .set =3D iris_set_level, }, { .cap_id =3D STAGE, @@ -279,6 +283,7 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8550_e= nc[] =3D { .step_or_mask =3D 1, .value =3D STAGE_2, .hfi_id =3D HFI_PROP_STAGE, + .set =3D iris_set_stage, }, { .cap_id =3D HEADER_MODE, @@ -289,6 +294,7 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8550_e= nc[] =3D { .value =3D V4L2_MPEG_VIDEO_HEADER_MODE_JOINED_WITH_1ST_FRAME, .hfi_id =3D HFI_PROP_SEQ_HEADER_MODE, .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + .set =3D iris_set_header_mode_gen2, }, { .cap_id =3D PREPEND_SPSPPS_TO_IDR, @@ -306,6 +312,7 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8550_e= nc[] =3D { .hfi_id =3D HFI_PROP_TOTAL_BITRATE, .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED, + .set =3D iris_set_bitrate, }, { .cap_id =3D BITRATE_PEAK, @@ -316,6 +323,7 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8550_e= nc[] =3D { .hfi_id =3D HFI_PROP_TOTAL_PEAK_BITRATE, .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED, + .set =3D iris_set_peak_bitrate, }, { .cap_id =3D BITRATE_MODE, @@ -326,6 +334,7 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8550_e= nc[] =3D { .value =3D V4L2_MPEG_VIDEO_BITRATE_MODE_VBR, .hfi_id =3D HFI_PROP_RATE_CONTROL, .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + .set =3D iris_set_bitrate_mode_gen2, }, { .cap_id =3D FRAME_SKIP_MODE, @@ -353,6 +362,7 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8550_e= nc[] =3D { .hfi_id =3D HFI_PROP_MAX_GOP_FRAMES, .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED, + .set =3D iris_set_u32, }, { .cap_id =3D ENTROPY_MODE, @@ -363,6 +373,7 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8550_e= nc[] =3D { .value =3D V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CABAC, .hfi_id =3D HFI_PROP_CABAC_SESSION, .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + .set =3D iris_set_entropy_mode_gen2, }, { .cap_id =3D MIN_FRAME_QP_H264, @@ -372,6 +383,7 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8550_e= nc[] =3D { .value =3D MIN_QP_8BIT, .hfi_id =3D HFI_PROP_MIN_QP_PACKED, .flags =3D CAP_FLAG_OUTPUT_PORT, + .set =3D iris_set_min_qp, }, { .cap_id =3D MIN_FRAME_QP_HEVC, @@ -381,6 +393,7 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8550_e= nc[] =3D { .value =3D MIN_QP_8BIT, .hfi_id =3D HFI_PROP_MIN_QP_PACKED, .flags =3D CAP_FLAG_OUTPUT_PORT, + .set =3D iris_set_min_qp, }, { .cap_id =3D MAX_FRAME_QP_H264, @@ -390,6 +403,7 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8550_e= nc[] =3D { .value =3D MIN_QP_8BIT, .hfi_id =3D HFI_PROP_MAX_QP_PACKED, .flags =3D CAP_FLAG_OUTPUT_PORT, + .set =3D iris_set_max_qp, }, { .cap_id =3D MAX_FRAME_QP_HEVC, @@ -399,6 +413,7 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8550_e= nc[] =3D { .value =3D MIN_QP_8BIT, .hfi_id =3D HFI_PROP_MAX_QP_PACKED, .flags =3D CAP_FLAG_OUTPUT_PORT, + .set =3D iris_set_max_qp, }, { .cap_id =3D I_FRAME_MIN_QP_H264, @@ -493,6 +508,7 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8550_e= nc[] =3D { .hfi_id =3D HFI_PROP_QP_PACKED, .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED, + .set =3D iris_set_frame_qp, }, { .cap_id =3D I_FRAME_QP_HEVC, @@ -503,6 +519,7 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8550_e= nc[] =3D { .hfi_id =3D HFI_PROP_QP_PACKED, .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED, + .set =3D iris_set_frame_qp, }, { .cap_id =3D P_FRAME_QP_H264, @@ -513,6 +530,7 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8550_e= nc[] =3D { .hfi_id =3D HFI_PROP_QP_PACKED, .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED, + .set =3D iris_set_frame_qp, }, { .cap_id =3D P_FRAME_QP_HEVC, @@ -523,6 +541,7 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8550_e= nc[] =3D { .hfi_id =3D HFI_PROP_QP_PACKED, .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED, + .set =3D iris_set_frame_qp, }, { .cap_id =3D B_FRAME_QP_H264, @@ -533,6 +552,7 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8550_e= nc[] =3D { .hfi_id =3D HFI_PROP_QP_PACKED, .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED, + .set =3D iris_set_frame_qp, }, { .cap_id =3D B_FRAME_QP_HEVC, @@ -543,6 +563,7 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8550_e= nc[] =3D { .hfi_id =3D HFI_PROP_QP_PACKED, .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED, + .set =3D iris_set_frame_qp, }, }; =20 diff --git a/drivers/media/platform/qcom/iris/iris_platform_sm8250.c b/driv= ers/media/platform/qcom/iris/iris_platform_sm8250.c index 34960d250d09dd872749dd19cdd3316e94575b81..cd09442be9675af9674f7467993= 2285d3c0197c1 100644 --- a/drivers/media/platform/qcom/iris/iris_platform_sm8250.c +++ b/drivers/media/platform/qcom/iris/iris_platform_sm8250.c @@ -45,6 +45,7 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8250_enc= [] =3D { .step_or_mask =3D 1, .value =3D STAGE_2, .hfi_id =3D HFI_PROPERTY_PARAM_WORK_MODE, + .set =3D iris_set_stage, }, { .cap_id =3D PROFILE_H264, @@ -59,6 +60,7 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8250_enc= [] =3D { .value =3D V4L2_MPEG_VIDEO_H264_PROFILE_HIGH, .hfi_id =3D HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT, .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + .set =3D iris_set_profile_level_gen1, }, { .cap_id =3D PROFILE_HEVC, @@ -70,6 +72,7 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8250_enc= [] =3D { .value =3D V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN, .hfi_id =3D HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT, .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + .set =3D iris_set_profile_level_gen1, }, { .cap_id =3D LEVEL_H264, @@ -94,6 +97,7 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8250_enc= [] =3D { .value =3D V4L2_MPEG_VIDEO_H264_LEVEL_1_0, .hfi_id =3D HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT, .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + .set =3D iris_set_profile_level_gen1, }, { .cap_id =3D LEVEL_HEVC, @@ -115,6 +119,7 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8250_e= nc[] =3D { .value =3D V4L2_MPEG_VIDEO_H264_LEVEL_1_0, .hfi_id =3D HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT, .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + .set =3D iris_set_profile_level_gen1, }, { .cap_id =3D HEADER_MODE, @@ -125,6 +130,7 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8250_e= nc[] =3D { .value =3D V4L2_MPEG_VIDEO_HEADER_MODE_JOINED_WITH_1ST_FRAME, .hfi_id =3D HFI_PROPERTY_CONFIG_VENC_SYNC_FRAME_SEQUENCE_HEADER, .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + .set =3D iris_set_header_mode_gen1, }, { .cap_id =3D BITRATE, @@ -135,6 +141,7 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8250_e= nc[] =3D { .hfi_id =3D HFI_PROPERTY_CONFIG_VENC_TARGET_BITRATE, .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED, + .set =3D iris_set_bitrate, }, { .cap_id =3D BITRATE_PEAK, @@ -145,6 +152,7 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8250_e= nc[] =3D { .hfi_id =3D HFI_PROPERTY_CONFIG_VENC_MAX_BITRATE, .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED, + .set =3D iris_set_peak_bitrate, }, { .cap_id =3D BITRATE_MODE, @@ -155,6 +163,7 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8250_e= nc[] =3D { .value =3D V4L2_MPEG_VIDEO_BITRATE_MODE_VBR, .hfi_id =3D HFI_PROPERTY_PARAM_VENC_RATE_CONTROL, .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + .set =3D iris_set_bitrate_mode_gen1, }, { .cap_id =3D FRAME_SKIP_MODE, @@ -178,6 +187,7 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8250_e= nc[] =3D { .max =3D (1 << 16) - 1, .step_or_mask =3D 1, .value =3D 30, + .set =3D iris_set_u32 }, { .cap_id =3D ENTROPY_MODE, @@ -188,6 +198,7 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8250_e= nc[] =3D { .value =3D V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CAVLC, .hfi_id =3D HFI_PROPERTY_PARAM_VENC_H264_ENTROPY_CONTROL, .flags =3D CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU, + .set =3D iris_set_entropy_mode_gen1, }, { .cap_id =3D MIN_FRAME_QP_H264, @@ -197,6 +208,7 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8250_e= nc[] =3D { .value =3D MIN_QP_8BIT, .hfi_id =3D HFI_PROPERTY_PARAM_VENC_SESSION_QP_RANGE_V2, .flags =3D CAP_FLAG_OUTPUT_PORT, + .set =3D iris_set_qp_range, }, { .cap_id =3D MIN_FRAME_QP_HEVC, @@ -206,6 +218,7 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8250_e= nc[] =3D { .value =3D MIN_QP_8BIT, .hfi_id =3D HFI_PROPERTY_PARAM_VENC_SESSION_QP_RANGE_V2, .flags =3D CAP_FLAG_OUTPUT_PORT, + .set =3D iris_set_qp_range, }, { .cap_id =3D MAX_FRAME_QP_H264, @@ -215,6 +228,7 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8250_e= nc[] =3D { .value =3D MAX_QP, .hfi_id =3D HFI_PROPERTY_PARAM_VENC_SESSION_QP_RANGE_V2, .flags =3D CAP_FLAG_OUTPUT_PORT, + .set =3D iris_set_qp_range, }, { .cap_id =3D MAX_FRAME_QP_HEVC, @@ -224,6 +238,7 @@ static struct platform_inst_fw_cap inst_fw_cap_sm8250_e= nc[] =3D { .value =3D MAX_QP_HEVC, .hfi_id =3D HFI_PROPERTY_PARAM_VENC_SESSION_QP_RANGE_V2, .flags =3D CAP_FLAG_OUTPUT_PORT, + .set =3D iris_set_qp_range, }, }; =20 --=20 2.34.1 From nobody Tue Oct 7 22:51:46 2025 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 91BF52EAD11; Fri, 4 Jul 2025 07:54:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615696; cv=none; b=vCmrxev8B+w6AUm/vrZHUmXIJ8t2ltH1HLBEajgljhLkJYa+5Ud+xHx3FuCseALnoyUnJ6VvLz6uctBM2lFazvDUGNc7BUlw/c5d5HQ8f6uhUUp9UUibLghgK7do6EtKWp7Qjy4jVSfQF8oDks7dpN6o6yjkp45iKNsQxwjBzNQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615696; c=relaxed/simple; bh=1L6y4Ocz3+WlWF8tQYsHqB7CyoVvEiErHhVjSOGPCso=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=tBLteaxPLqiR2lu9c+GtWwZVE55lt1whjimRP7SmAxRtB3+DYrKn/cHTx5GT3AC2bgQpEnD6NrKeF17h99lN9x9ENkT8RF5q18jttpqgOb1jzPsyPRIqKFYqHNEXRkAZBP+caLViDH8e2e92JXhxV7dDtQji4IGG58T8+UkvCRU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=ipDLcSR5; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="ipDLcSR5" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5645U6TU007345; Fri, 4 Jul 2025 07:54:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= g2u9Xa04qZrJPPyTmA4nzd88fd5y/ShONYZXR6QUK3o=; b=ipDLcSR5Ubd8EtKp QjlSKrnB9+ZFr0GZj4lc6nVDV5hjBrgY+ZxTW/2mciHjV0cl7P7zWOGd4XD1V0A8 njbB75nDCxX98YojLxVeaPoDAGnFJj0y2EpFDCMNy6s/EHtGblpZ5Oorb3affVWg dyPWErvl4w85X5iht+tA+D+ULZBJr7/LoBvVF7ZzxSWITJKeKXp2x0prDiwcbH8G FqY11MMZH/6Oo4LGititRd0rKp+J9odnh2ra6+/7dVzrQrYy7nK5f4boNJJwU8hX lE3xBP6Fw8X6+WKfPuSoVm7hOTWR7cX5SuWCC8R9weJcbs58tWoCpz+nDqUzwzMP Pmw3/Q== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 47kn5jqgvx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Jul 2025 07:54:41 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA02.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 5647sffq026542 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 4 Jul 2025 07:54:41 GMT Received: from hu-dikshita-hyd.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Fri, 4 Jul 2025 00:54:37 -0700 From: Dikshita Agarwal Date: Fri, 4 Jul 2025 13:23:23 +0530 Subject: [PATCH 23/25] media: iris: Allocate and queue internal buffers for encoder video device Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20250704-iris-video-encoder-v1-23-b6ce24e273cf@quicinc.com> References: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> In-Reply-To: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> To: Vikash Garodia , Abhinav Kumar , Bryan O'Donoghue , Mauro Carvalho Chehab , Hans Verkuil , Stefan Schmidt , "Vedang Nagar" CC: , , , Dikshita Agarwal X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1751615599; l=56204; i=quic_dikshita@quicinc.com; s=20240917; h=from:subject:message-id; bh=1L6y4Ocz3+WlWF8tQYsHqB7CyoVvEiErHhVjSOGPCso=; b=4nFaIX2DnnzNrmsJQP0AZtB5tx2x+5Bnz6OxkgDn/jiQV0aUXXAw5KX2ggzyGV3h9pUR3biFk stjds4OFiUsAlzv605UYwvswOTiz6aUdqEIbDwvSZVAm59lOC0Lrw6d X-Developer-Key: i=quic_dikshita@quicinc.com; a=ed25519; pk=EEvKY6Ar1OI5SWf44FJ1Ebo1KuQEVbbf5UNPO+UHVhM= X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Authority-Analysis: v=2.4 cv=KtJN2XWN c=1 sm=1 tr=0 ts=686788c2 cx=c_pps a=JYp8KDb2vCoCEuGobkYCKw==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=GEpy-HfZoHoA:10 a=IkcTkHD0fZMA:10 a=Wb1JkmetP80A:10 a=COk6AnOGAAAA:8 a=w1rVzjzx0pa-1t0gukAA:9 a=QEXdDO2ut3YA:10 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-ORIG-GUID: 0P9hm87nCDexFaDjgOQ58D3IxN7pqxdZ X-Proofpoint-GUID: 0P9hm87nCDexFaDjgOQ58D3IxN7pqxdZ X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzA0MDA2MCBTYWx0ZWRfX9HMKqzWv8iTe vNgA9VisdTXA2u7dz2NdgMg/lepG9CYRjT+1M2td7Wx/6Wh3MoYFknJop5/ZbCg8E/UDm5CEI1a ccuTPhzdQ7YcuimeXRFvCC8sG3RIid36OhexoEuTmR0IS7nGRbKkh/LMlw7YFjK/VvKHBENisW4 iHldGEcjVEjtpHJ/SzaqhAQgKrCzstLYMkvHIWTKPbsMUd7TfjO4C6p6xHOPyLQGNTgqjmzTUuj 0HwUlptG1OcpSTBmM7Q3pH6AVbtCjJochAmPFzwlkba1F1fbfDgrauu7gAnEiUy16TpUS+6JRyD q8hEAM5ydF0k41nJlojdtqzIoipZDlRUzF2k2YN6BTynGqoV2WzuMQ6MiVEEMfY8R2xhmeeNp+a iNie7h/b52Xwj9MxSMGFgIg8v72vHBVogjIFIEh5tb8H1oOUW45xoOumLBenkj6H4YGM0qW+ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-04_03,2025-07-02_04,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 bulkscore=0 priorityscore=1501 malwarescore=0 suspectscore=0 mlxscore=0 spamscore=0 adultscore=0 lowpriorityscore=0 phishscore=0 clxscore=1015 mlxlogscore=999 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507040060 Add support for allocating and queuing internal buffers required by the encoder. The sizes of these buffers are derived from hardware specifications and are essential to meet the encoder's functional and performance requirements. These buffers are not exposed to userspace; they are allocated and managed internally to ensure correct and efficient hardware operation. Signed-off-by: Dikshita Agarwal Tested-by: Vikash Garodia # X1E80100 --- drivers/media/platform/qcom/iris/iris_buffer.c | 114 ++- drivers/media/platform/qcom/iris/iris_buffer.h | 4 +- .../platform/qcom/iris/iris_hfi_gen1_command.c | 6 + .../platform/qcom/iris/iris_hfi_gen1_defines.h | 2 + .../platform/qcom/iris/iris_hfi_gen2_command.c | 56 +- .../platform/qcom/iris/iris_hfi_gen2_response.c | 10 +- .../platform/qcom/iris/iris_platform_common.h | 4 + .../media/platform/qcom/iris/iris_platform_gen2.c | 17 + .../platform/qcom/iris/iris_platform_sm8250.c | 9 + drivers/media/platform/qcom/iris/iris_vdec.c | 2 +- drivers/media/platform/qcom/iris/iris_venc.c | 36 + drivers/media/platform/qcom/iris/iris_vidc.c | 7 +- drivers/media/platform/qcom/iris/iris_vpu_buffer.c | 841 +++++++++++++++++= +++- drivers/media/platform/qcom/iris/iris_vpu_buffer.h | 20 + 14 files changed, 1071 insertions(+), 57 deletions(-) diff --git a/drivers/media/platform/qcom/iris/iris_buffer.c b/drivers/media= /platform/qcom/iris/iris_buffer.c index 8ec10e6058f2b66c923a9925048f90537603004b..9df6788cefda72352ebe79013c7= 8d0b57d29ed9f 100644 --- a/drivers/media/platform/qcom/iris/iris_buffer.c +++ b/drivers/media/platform/qcom/iris/iris_buffer.c @@ -294,16 +294,30 @@ void iris_get_internal_buffers(struct iris_inst *inst= , u32 plane) const u32 *internal_buf_type; u32 internal_buffer_count, i; =20 - if (V4L2_TYPE_IS_OUTPUT(plane)) { - internal_buf_type =3D platform_data->dec_ip_int_buf_tbl; - internal_buffer_count =3D platform_data->dec_ip_int_buf_tbl_size; - for (i =3D 0; i < internal_buffer_count; i++) - iris_fill_internal_buf_info(inst, internal_buf_type[i]); + if (inst->domain =3D=3D DECODER) { + if (V4L2_TYPE_IS_OUTPUT(plane)) { + internal_buf_type =3D platform_data->dec_ip_int_buf_tbl; + internal_buffer_count =3D platform_data->dec_ip_int_buf_tbl_size; + for (i =3D 0; i < internal_buffer_count; i++) + iris_fill_internal_buf_info(inst, internal_buf_type[i]); + } else { + internal_buf_type =3D platform_data->dec_op_int_buf_tbl; + internal_buffer_count =3D platform_data->dec_op_int_buf_tbl_size; + for (i =3D 0; i < internal_buffer_count; i++) + iris_fill_internal_buf_info(inst, internal_buf_type[i]); + } } else { - internal_buf_type =3D platform_data->dec_op_int_buf_tbl; - internal_buffer_count =3D platform_data->dec_op_int_buf_tbl_size; - for (i =3D 0; i < internal_buffer_count; i++) - iris_fill_internal_buf_info(inst, internal_buf_type[i]); + if (V4L2_TYPE_IS_OUTPUT(plane)) { + internal_buf_type =3D platform_data->enc_ip_int_buf_tbl; + internal_buffer_count =3D platform_data->enc_ip_int_buf_tbl_size; + for (i =3D 0; i < internal_buffer_count; i++) + iris_fill_internal_buf_info(inst, internal_buf_type[i]); + } else { + internal_buf_type =3D platform_data->enc_op_int_buf_tbl; + internal_buffer_count =3D platform_data->enc_op_int_buf_tbl_size; + for (i =3D 0; i < internal_buffer_count; i++) + iris_fill_internal_buf_info(inst, internal_buf_type[i]); + } } } =20 @@ -344,12 +358,22 @@ int iris_create_internal_buffers(struct iris_inst *in= st, u32 plane) const u32 *internal_buf_type; int ret; =20 - if (V4L2_TYPE_IS_OUTPUT(plane)) { - internal_buf_type =3D platform_data->dec_ip_int_buf_tbl; - internal_buffer_count =3D platform_data->dec_ip_int_buf_tbl_size; + if (inst->domain =3D=3D DECODER) { + if (V4L2_TYPE_IS_OUTPUT(plane)) { + internal_buf_type =3D platform_data->dec_ip_int_buf_tbl; + internal_buffer_count =3D platform_data->dec_ip_int_buf_tbl_size; + } else { + internal_buf_type =3D platform_data->dec_op_int_buf_tbl; + internal_buffer_count =3D platform_data->dec_op_int_buf_tbl_size; + } } else { - internal_buf_type =3D platform_data->dec_op_int_buf_tbl; - internal_buffer_count =3D platform_data->dec_op_int_buf_tbl_size; + if (V4L2_TYPE_IS_OUTPUT(plane)) { + internal_buf_type =3D platform_data->enc_ip_int_buf_tbl; + internal_buffer_count =3D platform_data->enc_ip_int_buf_tbl_size; + } else { + internal_buf_type =3D platform_data->enc_op_int_buf_tbl; + internal_buffer_count =3D platform_data->enc_op_int_buf_tbl_size; + } } =20 for (i =3D 0; i < internal_buffer_count; i++) { @@ -411,12 +435,22 @@ int iris_queue_internal_buffers(struct iris_inst *ins= t, u32 plane) u32 internal_buffer_count, i; int ret; =20 - if (V4L2_TYPE_IS_OUTPUT(plane)) { - internal_buf_type =3D platform_data->dec_ip_int_buf_tbl; - internal_buffer_count =3D platform_data->dec_ip_int_buf_tbl_size; + if (inst->domain =3D=3D DECODER) { + if (V4L2_TYPE_IS_OUTPUT(plane)) { + internal_buf_type =3D platform_data->dec_ip_int_buf_tbl; + internal_buffer_count =3D platform_data->dec_ip_int_buf_tbl_size; + } else { + internal_buf_type =3D platform_data->dec_op_int_buf_tbl; + internal_buffer_count =3D platform_data->dec_op_int_buf_tbl_size; + } } else { - internal_buf_type =3D platform_data->dec_op_int_buf_tbl; - internal_buffer_count =3D platform_data->dec_op_int_buf_tbl_size; + if (V4L2_TYPE_IS_OUTPUT(plane)) { + internal_buf_type =3D platform_data->enc_ip_int_buf_tbl; + internal_buffer_count =3D platform_data->enc_ip_int_buf_tbl_size; + } else { + internal_buf_type =3D platform_data->enc_op_int_buf_tbl; + internal_buffer_count =3D platform_data->enc_op_int_buf_tbl_size; + } } =20 for (i =3D 0; i < internal_buffer_count; i++) { @@ -460,12 +494,22 @@ static int iris_destroy_internal_buffers(struct iris_= inst *inst, u32 plane, bool u32 i, len; int ret; =20 - if (V4L2_TYPE_IS_OUTPUT(plane)) { - internal_buf_type =3D platform_data->dec_ip_int_buf_tbl; - len =3D platform_data->dec_ip_int_buf_tbl_size; + if (inst->domain =3D=3D DECODER) { + if (V4L2_TYPE_IS_OUTPUT(plane)) { + internal_buf_type =3D platform_data->dec_ip_int_buf_tbl; + len =3D platform_data->dec_ip_int_buf_tbl_size; + } else { + internal_buf_type =3D platform_data->dec_op_int_buf_tbl; + len =3D platform_data->dec_op_int_buf_tbl_size; + } } else { - internal_buf_type =3D platform_data->dec_op_int_buf_tbl; - len =3D platform_data->dec_op_int_buf_tbl_size; + if (V4L2_TYPE_IS_OUTPUT(plane)) { + internal_buf_type =3D platform_data->enc_ip_int_buf_tbl; + len =3D platform_data->enc_ip_int_buf_tbl_size; + } else { + internal_buf_type =3D platform_data->enc_op_int_buf_tbl; + len =3D platform_data->enc_op_int_buf_tbl_size; + } } =20 for (i =3D 0; i < len; i++) { @@ -486,7 +530,10 @@ static int iris_destroy_internal_buffers(struct iris_i= nst *inst, u32 plane, bool } =20 if (force) { - buffers =3D &inst->buffers[BUF_PERSIST]; + if (inst->domain =3D=3D DECODER) + buffers =3D &inst->buffers[BUF_PERSIST]; + else + buffers =3D &inst->buffers[BUF_ARP]; =20 list_for_each_entry_safe(buf, next, &buffers->list, list) { ret =3D iris_destroy_internal_buffer(inst, buf); @@ -537,8 +584,13 @@ static int iris_release_input_internal_buffers(struct = iris_inst *inst) u32 internal_buffer_count, i; int ret; =20 - internal_buf_type =3D platform_data->dec_ip_int_buf_tbl; - internal_buffer_count =3D platform_data->dec_ip_int_buf_tbl_size; + if (inst->domain =3D=3D DECODER) { + internal_buf_type =3D platform_data->dec_ip_int_buf_tbl; + internal_buffer_count =3D platform_data->dec_ip_int_buf_tbl_size; + } else { + internal_buf_type =3D platform_data->enc_ip_int_buf_tbl; + internal_buffer_count =3D platform_data->enc_ip_int_buf_tbl_size; + } =20 for (i =3D 0; i < internal_buffer_count; i++) { ret =3D iris_release_internal_buffers(inst, internal_buf_type[i]); @@ -549,9 +601,9 @@ static int iris_release_input_internal_buffers(struct i= ris_inst *inst) return 0; } =20 -int iris_alloc_and_queue_persist_bufs(struct iris_inst *inst) +int iris_alloc_and_queue_persist_bufs(struct iris_inst *inst, enum iris_bu= ffer_type buffer_type) { - struct iris_buffers *buffers =3D &inst->buffers[BUF_PERSIST]; + struct iris_buffers *buffers =3D &inst->buffers[buffer_type]; struct iris_buffer *buffer, *next; int ret; u32 i; @@ -559,10 +611,10 @@ int iris_alloc_and_queue_persist_bufs(struct iris_ins= t *inst) if (!list_empty(&buffers->list)) return 0; =20 - iris_fill_internal_buf_info(inst, BUF_PERSIST); + iris_fill_internal_buf_info(inst, buffer_type); =20 for (i =3D 0; i < buffers->min_count; i++) { - ret =3D iris_create_internal_buffer(inst, BUF_PERSIST, i); + ret =3D iris_create_internal_buffer(inst, buffer_type, i); if (ret) return ret; } diff --git a/drivers/media/platform/qcom/iris/iris_buffer.h b/drivers/media= /platform/qcom/iris/iris_buffer.h index b9b011faa13ae72e08545c191cdcc2f1bcaf9e0a..0f7a16597dfa68827d5ed25150f= 9082052d08fb0 100644 --- a/drivers/media/platform/qcom/iris/iris_buffer.h +++ b/drivers/media/platform/qcom/iris/iris_buffer.h @@ -38,6 +38,8 @@ enum iris_buffer_type { BUF_DPB, BUF_PERSIST, BUF_SCRATCH_1, + BUF_SCRATCH_2, + BUF_VPSS, BUF_TYPE_MAX, }; =20 @@ -109,7 +111,7 @@ int iris_queue_internal_deferred_buffers(struct iris_in= st *inst, enum iris_buffe int iris_destroy_internal_buffer(struct iris_inst *inst, struct iris_buffe= r *buffer); int iris_destroy_all_internal_buffers(struct iris_inst *inst, u32 plane); int iris_destroy_dequeued_internal_buffers(struct iris_inst *inst, u32 pla= ne); -int iris_alloc_and_queue_persist_bufs(struct iris_inst *inst); +int iris_alloc_and_queue_persist_bufs(struct iris_inst *inst, enum iris_bu= ffer_type buf_type); int iris_alloc_and_queue_input_int_bufs(struct iris_inst *inst); int iris_queue_buffer(struct iris_inst *inst, struct iris_buffer *buf); int iris_queue_deferred_buffers(struct iris_inst *inst, enum iris_buffer_t= ype buf_type); diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c b/dri= vers/media/platform/qcom/iris/iris_hfi_gen1_command.c index a575d618a341cceb5b06257466994544a5e61862..e4c9694e29a2a6c5ab4d31184c5= e000ffc417390 100644 --- a/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c @@ -21,6 +21,10 @@ static u32 iris_hfi_gen1_buf_type_from_driver(enum iris_= buffer_type buffer_type) return HFI_BUFFER_INTERNAL_SCRATCH; case BUF_SCRATCH_1: return HFI_BUFFER_INTERNAL_SCRATCH_1; + case BUF_SCRATCH_2: + return HFI_BUFFER_INTERNAL_SCRATCH_2; + case BUF_ARP: + return HFI_BUFFER_INTERNAL_PERSIST; default: return -EINVAL; } @@ -363,6 +367,8 @@ static int iris_hfi_gen1_session_queue_buffer(struct ir= is_inst *inst, struct iri case BUF_PERSIST: case BUF_BIN: case BUF_SCRATCH_1: + case BUF_SCRATCH_2: + case BUF_ARP: return iris_hfi_gen1_queue_internal_buffer(inst, buf); default: return -EINVAL; diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen1_defines.h b/dri= vers/media/platform/qcom/iris/iris_hfi_gen1_defines.h index 6ce166fb42c7ae4823f88d7303d651752018ea2d..e96e09f08e62bd56ab639b94d2b= 9a469554c544c 100644 --- a/drivers/media/platform/qcom/iris/iris_hfi_gen1_defines.h +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen1_defines.h @@ -74,9 +74,11 @@ #define HFI_BUFFER_INPUT 0x1 #define HFI_BUFFER_OUTPUT 0x2 #define HFI_BUFFER_OUTPUT2 0x3 +#define HFI_BUFFER_INTERNAL_PERSIST 0x4 #define HFI_BUFFER_INTERNAL_PERSIST_1 0x5 #define HFI_BUFFER_INTERNAL_SCRATCH 0x6 #define HFI_BUFFER_INTERNAL_SCRATCH_1 0x7 +#define HFI_BUFFER_INTERNAL_SCRATCH_2 0x8 =20 #define HFI_PROPERTY_SYS_CODEC_POWER_PLANE_CTRL 0x5 #define HFI_PROPERTY_SYS_IMAGE_VERSION 0x6 diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c b/dri= vers/media/platform/qcom/iris/iris_hfi_gen2_command.c index 4cdceca3f8a05a6ec9ad76e7cbaa138daba0e958..c71be09211bdc41fdb38551a6c4= 16d1d252bec56 100644 --- a/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c @@ -111,21 +111,40 @@ static u32 iris_hfi_gen2_get_port(struct iris_inst *i= nst, u32 plane) } } =20 -static u32 iris_hfi_gen2_get_port_from_buf_type(enum iris_buffer_type buff= er_type) +static u32 iris_hfi_gen2_get_port_from_buf_type(struct iris_inst *inst, + enum iris_buffer_type buffer_type) { - switch (buffer_type) { - case BUF_INPUT: - case BUF_BIN: - case BUF_COMV: - case BUF_NON_COMV: - case BUF_LINE: - return HFI_PORT_BITSTREAM; - case BUF_OUTPUT: - case BUF_DPB: - return HFI_PORT_RAW; - case BUF_PERSIST: - default: - return HFI_PORT_NONE; + if (inst->domain =3D=3D DECODER) { + switch (buffer_type) { + case BUF_INPUT: + case BUF_BIN: + case BUF_COMV: + case BUF_NON_COMV: + case BUF_LINE: + return HFI_PORT_BITSTREAM; + case BUF_OUTPUT: + case BUF_DPB: + return HFI_PORT_RAW; + case BUF_PERSIST: + default: + return HFI_PORT_NONE; + } + } else { + switch (buffer_type) { + case BUF_INPUT: + case BUF_VPSS: + return HFI_PORT_RAW; + case BUF_OUTPUT: + case BUF_BIN: + case BUF_COMV: + case BUF_NON_COMV: + case BUF_LINE: + case BUF_SCRATCH_2: + return HFI_PORT_BITSTREAM; + case BUF_ARP: + default: + return HFI_PORT_NONE; + } } } =20 @@ -1040,9 +1059,14 @@ static u32 iris_hfi_gen2_buf_type_from_driver(enum i= ris_buffer_type buffer_type) case BUF_LINE: return HFI_BUFFER_LINE; case BUF_DPB: + case BUF_SCRATCH_2: return HFI_BUFFER_DPB; case BUF_PERSIST: return HFI_BUFFER_PERSIST; + case BUF_ARP: + return HFI_BUFFER_ARP; + case BUF_VPSS: + return HFI_BUFFER_VPSS; default: return 0; } @@ -1098,7 +1122,7 @@ static int iris_hfi_gen2_session_queue_buffer(struct = iris_inst *inst, struct iri return ret; } =20 - port =3D iris_hfi_gen2_get_port_from_buf_type(buffer->type); + port =3D iris_hfi_gen2_get_port_from_buf_type(inst, buffer->type); iris_hfi_gen2_packet_session_command(inst, HFI_CMD_BUFFER, HFI_HOST_FLAGS_INTR_REQUIRED, @@ -1120,7 +1144,7 @@ static int iris_hfi_gen2_session_release_buffer(struc= t iris_inst *inst, struct i =20 iris_hfi_gen2_get_buffer(buffer, &hfi_buffer); hfi_buffer.flags |=3D HFI_BUF_HOST_FLAG_RELEASE; - port =3D iris_hfi_gen2_get_port_from_buf_type(buffer->type); + port =3D iris_hfi_gen2_get_port_from_buf_type(inst, buffer->type); =20 iris_hfi_gen2_packet_session_command(inst, HFI_CMD_BUFFER, diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c b/dr= ivers/media/platform/qcom/iris/iris_hfi_gen2_response.c index 4e4fae2359ccf210186397a417049208728b5d53..6b8e637ac6d82aee8699db59ee2= f04de9e715275 100644 --- a/drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c @@ -29,7 +29,8 @@ struct iris_hfi_gen2_packet_handle { int (*handle)(struct iris_inst *inst, struct iris_hfi_packet *pkt); }; =20 -static u32 iris_hfi_gen2_buf_type_to_driver(enum hfi_buffer_type buf_type) +static u32 iris_hfi_gen2_buf_type_to_driver(struct iris_inst *inst, + enum hfi_buffer_type buf_type) { switch (buf_type) { case HFI_BUFFER_BITSTREAM: @@ -47,7 +48,10 @@ static u32 iris_hfi_gen2_buf_type_to_driver(enum hfi_buf= fer_type buf_type) case HFI_BUFFER_LINE: return BUF_LINE; case HFI_BUFFER_DPB: - return BUF_DPB; + if (inst->domain =3D=3D DECODER) + return BUF_DPB; + else + return BUF_SCRATCH_2; case HFI_BUFFER_PERSIST: return BUF_PERSIST; default: @@ -421,7 +425,7 @@ static void iris_hfi_gen2_handle_dequeue_buffers(struct= iris_inst *inst) static int iris_hfi_gen2_handle_release_internal_buffer(struct iris_inst *= inst, struct iris_hfi_buffer *buffer) { - u32 buf_type =3D iris_hfi_gen2_buf_type_to_driver(buffer->type); + u32 buf_type =3D iris_hfi_gen2_buf_type_to_driver(inst, buffer->type); struct iris_buffers *buffers =3D &inst->buffers[buf_type]; struct iris_buffer *buf, *iter; bool found =3D false; diff --git a/drivers/media/platform/qcom/iris/iris_platform_common.h b/driv= ers/media/platform/qcom/iris/iris_platform_common.h index f89dcd3347d8c95c14cee6192dfa91389da69d37..65cee5711b98538c14f15d3db9d= 47b402d2e9562 100644 --- a/drivers/media/platform/qcom/iris/iris_platform_common.h +++ b/drivers/media/platform/qcom/iris/iris_platform_common.h @@ -246,6 +246,10 @@ struct iris_platform_data { unsigned int dec_ip_int_buf_tbl_size; const u32 *dec_op_int_buf_tbl; unsigned int dec_op_int_buf_tbl_size; + const u32 *enc_ip_int_buf_tbl; + unsigned int enc_ip_int_buf_tbl_size; + const u32 *enc_op_int_buf_tbl; + unsigned int enc_op_int_buf_tbl_size; }; =20 #endif diff --git a/drivers/media/platform/qcom/iris/iris_platform_gen2.c b/driver= s/media/platform/qcom/iris/iris_platform_gen2.c index 8c0dd09c592df1c679e3e98590ba1b430c6d21c9..03ffc9abadba6b8ba2016e59d63= 8f1c98bca1f6a 100644 --- a/drivers/media/platform/qcom/iris/iris_platform_gen2.c +++ b/drivers/media/platform/qcom/iris/iris_platform_gen2.c @@ -706,6 +706,14 @@ static const u32 sm8550_dec_op_int_buf_tbl[] =3D { BUF_DPB, }; =20 +static const u32 sm8550_enc_op_int_buf_tbl[] =3D { + BUF_BIN, + BUF_COMV, + BUF_NON_COMV, + BUF_LINE, + BUF_SCRATCH_2, +}; + struct iris_platform_data sm8550_data =3D { .get_instance =3D iris_hfi_gen2_get_instance, .init_hfi_command_ops =3D iris_hfi_gen2_command_ops_init, @@ -783,6 +791,9 @@ struct iris_platform_data sm8550_data =3D { .dec_ip_int_buf_tbl_size =3D ARRAY_SIZE(sm8550_dec_ip_int_buf_tbl), .dec_op_int_buf_tbl =3D sm8550_dec_op_int_buf_tbl, .dec_op_int_buf_tbl_size =3D ARRAY_SIZE(sm8550_dec_op_int_buf_tbl), + + .enc_op_int_buf_tbl =3D sm8550_enc_op_int_buf_tbl, + .enc_op_int_buf_tbl_size =3D ARRAY_SIZE(sm8550_enc_op_int_buf_tbl), }; =20 /* @@ -871,6 +882,9 @@ struct iris_platform_data sm8650_data =3D { .dec_ip_int_buf_tbl_size =3D ARRAY_SIZE(sm8550_dec_ip_int_buf_tbl), .dec_op_int_buf_tbl =3D sm8550_dec_op_int_buf_tbl, .dec_op_int_buf_tbl_size =3D ARRAY_SIZE(sm8550_dec_op_int_buf_tbl), + + .enc_op_int_buf_tbl =3D sm8550_enc_op_int_buf_tbl, + .enc_op_int_buf_tbl_size =3D ARRAY_SIZE(sm8550_enc_op_int_buf_tbl), }; =20 /* @@ -955,4 +969,7 @@ struct iris_platform_data qcs8300_data =3D { .dec_ip_int_buf_tbl_size =3D ARRAY_SIZE(sm8550_dec_ip_int_buf_tbl), .dec_op_int_buf_tbl =3D sm8550_dec_op_int_buf_tbl, .dec_op_int_buf_tbl_size =3D ARRAY_SIZE(sm8550_dec_op_int_buf_tbl), + + .enc_op_int_buf_tbl =3D sm8550_enc_op_int_buf_tbl, + .enc_op_int_buf_tbl_size =3D ARRAY_SIZE(sm8550_enc_op_int_buf_tbl), }; diff --git a/drivers/media/platform/qcom/iris/iris_platform_sm8250.c b/driv= ers/media/platform/qcom/iris/iris_platform_sm8250.c index cd09442be9675af9674f74679932285d3c0197c1..a3dc74f299e3eab88175ebfca95= b31a03efda250 100644 --- a/drivers/media/platform/qcom/iris/iris_platform_sm8250.c +++ b/drivers/media/platform/qcom/iris/iris_platform_sm8250.c @@ -318,6 +318,12 @@ static const u32 sm8250_dec_op_int_buf_tbl[] =3D { BUF_DPB, }; =20 +static const u32 sm8250_enc_ip_int_buf_tbl[] =3D { + BUF_BIN, + BUF_SCRATCH_1, + BUF_SCRATCH_2, +}; + struct iris_platform_data sm8250_data =3D { .get_instance =3D iris_hfi_gen1_get_instance, .init_hfi_command_ops =3D &iris_hfi_gen1_command_ops_init, @@ -363,4 +369,7 @@ struct iris_platform_data sm8250_data =3D { .dec_ip_int_buf_tbl_size =3D ARRAY_SIZE(sm8250_dec_ip_int_buf_tbl), .dec_op_int_buf_tbl =3D sm8250_dec_op_int_buf_tbl, .dec_op_int_buf_tbl_size =3D ARRAY_SIZE(sm8250_dec_op_int_buf_tbl), + + .enc_ip_int_buf_tbl =3D sm8250_enc_ip_int_buf_tbl, + .enc_ip_int_buf_tbl_size =3D ARRAY_SIZE(sm8250_enc_ip_int_buf_tbl), }; diff --git a/drivers/media/platform/qcom/iris/iris_vdec.c b/drivers/media/p= latform/qcom/iris/iris_vdec.c index f091ef45d2a5f93db066dd13afff42b26e8b0155..86b5364651f587f92abcbef7b2f= 2a2c73f21b6b8 100644 --- a/drivers/media/platform/qcom/iris/iris_vdec.c +++ b/drivers/media/platform/qcom/iris/iris_vdec.c @@ -321,7 +321,7 @@ int iris_vdec_streamon_input(struct iris_inst *inst) if (ret) return ret; =20 - ret =3D iris_alloc_and_queue_persist_bufs(inst); + ret =3D iris_alloc_and_queue_persist_bufs(inst, BUF_PERSIST); if (ret) return ret; =20 diff --git a/drivers/media/platform/qcom/iris/iris_venc.c b/drivers/media/p= latform/qcom/iris/iris_venc.c index 4b0da51e0477ab00019396242be9fd585c11ded3..bd5e8fc2d48882c4fd57607a0ce= 5183c65272cf9 100644 --- a/drivers/media/platform/qcom/iris/iris_venc.c +++ b/drivers/media/platform/qcom/iris/iris_venc.c @@ -435,6 +435,24 @@ int iris_venc_streamon_input(struct iris_inst *inst) if (ret) return ret; =20 + ret =3D iris_alloc_and_queue_persist_bufs(inst, BUF_ARP); + if (ret) + return ret; + + iris_get_internal_buffers(inst, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); + + ret =3D iris_destroy_dequeued_internal_buffers(inst, V4L2_BUF_TYPE_VIDEO_= OUTPUT_MPLANE); + if (ret) + return ret; + + ret =3D iris_create_internal_buffers(inst, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPL= ANE); + if (ret) + return ret; + + ret =3D iris_queue_internal_buffers(inst, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLA= NE); + if (ret) + return ret; + return iris_process_streamon_input(inst); } =20 @@ -446,6 +464,24 @@ int iris_venc_streamon_output(struct iris_inst *inst) if (ret) goto error; =20 + ret =3D iris_alloc_and_queue_persist_bufs(inst, BUF_ARP); + if (ret) + return ret; + + iris_get_internal_buffers(inst, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); + + ret =3D iris_destroy_dequeued_internal_buffers(inst, V4L2_BUF_TYPE_VIDEO_= CAPTURE_MPLANE); + if (ret) + goto error; + + ret =3D iris_create_internal_buffers(inst, V4L2_BUF_TYPE_VIDEO_CAPTURE_MP= LANE); + if (ret) + goto error; + + ret =3D iris_queue_internal_buffers(inst, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPL= ANE); + if (ret) + goto error; + ret =3D iris_process_streamon_output(inst); if (ret) goto error; diff --git a/drivers/media/platform/qcom/iris/iris_vidc.c b/drivers/media/p= latform/qcom/iris/iris_vidc.c index be8688140fd22ffd02e8c286bfc5f62e050ceb5b..c2b86bb4c7d42aee8ecf2f8b9ef= 0015d06e82b04 100644 --- a/drivers/media/platform/qcom/iris/iris_vidc.c +++ b/drivers/media/platform/qcom/iris/iris_vidc.c @@ -176,6 +176,8 @@ int iris_open(struct file *filp) INIT_LIST_HEAD(&inst->buffers[BUF_DPB].list); INIT_LIST_HEAD(&inst->buffers[BUF_PERSIST].list); INIT_LIST_HEAD(&inst->buffers[BUF_SCRATCH_1].list); + INIT_LIST_HEAD(&inst->buffers[BUF_SCRATCH_2].list); + INIT_LIST_HEAD(&inst->buffers[BUF_VPSS].list); init_completion(&inst->completion); init_completion(&inst->flush_completion); =20 @@ -266,7 +268,10 @@ static void iris_check_num_queued_internal_buffers(str= uct iris_inst *inst, u32 p count, internal_buf_type[i]); } =20 - buffers =3D &inst->buffers[BUF_PERSIST]; + if (inst->domain =3D=3D DECODER) + buffers =3D &inst->buffers[BUF_PERSIST]; + else + buffers =3D &inst->buffers[BUF_ARP]; =20 count =3D 0; list_for_each_entry_safe(buf, next, &buffers->list, list) diff --git a/drivers/media/platform/qcom/iris/iris_vpu_buffer.c b/drivers/m= edia/platform/qcom/iris/iris_vpu_buffer.c index 06d5afc3c641f0dfca3967e55273c4fa2614fdff..25974cb3870336e68cd18e472af= 54ab5fb348dd5 100644 --- a/drivers/media/platform/qcom/iris/iris_vpu_buffer.c +++ b/drivers/media/platform/qcom/iris/iris_vpu_buffer.c @@ -5,6 +5,14 @@ =20 #include "iris_instance.h" #include "iris_vpu_buffer.h" +#include "iris_hfi_gen1_defines.h" +#include "iris_hfi_gen2_defines.h" + +#define HFI_MAX_COL_FRAME 6 + +#ifndef SYSTEM_LAL_TILE10 +#define SYSTEM_LAL_TILE10 192 +#endif =20 static u32 size_h264d_hw_bin_buffer(u32 frame_width, u32 frame_height, u32= num_vpp_pipes) { @@ -548,6 +556,812 @@ static u32 iris_vpu_dec_scratch1_size(struct iris_ins= t *inst) iris_vpu_dec_line_size(inst); } =20 +static inline +u32 size_enc_single_pipe(u32 rc_type, u32 bitbin_size, u32 num_vpp_pipes, + u32 frame_width, u32 frame_height, u32 lcu_size) +{ + u32 size_aligned_height =3D ALIGN((frame_height), lcu_size); + u32 size_aligned_width =3D ALIGN((frame_width), lcu_size); + u32 size_single_pipe_eval =3D 0, sao_bin_buffer_size =3D 0; + u32 padded_bin_sz; + + if ((size_aligned_width * size_aligned_height) > (3840 * 2160)) + size_single_pipe_eval =3D (bitbin_size / num_vpp_pipes); + else if (num_vpp_pipes > 2) + size_single_pipe_eval =3D bitbin_size / 2; + else + size_single_pipe_eval =3D bitbin_size; + + sao_bin_buffer_size =3D (64 * ((((frame_width) + 32) * ((frame_height) + = 32)) >> 10)) + 384; + padded_bin_sz =3D ALIGN(size_single_pipe_eval, 256); + size_single_pipe_eval =3D sao_bin_buffer_size + padded_bin_sz; + + return ALIGN(size_single_pipe_eval, 256); +} + +static inline u32 size_bin_bitstream_enc(u32 width, u32 height, + u32 rc_type) +{ + u32 aligned_height =3D ALIGN(height, 32); + u32 aligned_width =3D ALIGN(width, 32); + u32 frame_size =3D width * height * 3; + u32 mbs_per_frame; + + /* + * Encoder output size calculation: 32 Align width/height + * For resolution < 720p : YUVsize * 4 + * For resolution > 720p & <=3D 4K : YUVsize / 2 + * For resolution > 4k : YUVsize / 4 + * Initially frame_size =3D YUVsize * 2; + */ + + mbs_per_frame =3D (ALIGN(aligned_height, 16) * ALIGN(aligned_width, 16)) = / 256; + + if (mbs_per_frame < NUM_MBS_720P) + frame_size =3D frame_size << 1; + else if (mbs_per_frame <=3D NUM_MBS_4K) + frame_size =3D frame_size >> 2; + else + frame_size =3D frame_size >> 3; + + if (rc_type =3D=3D HFI_RATE_CONTROL_OFF || rc_type =3D=3D HFI_RATE_CONTRO= L_CQ) + frame_size =3D frame_size << 1; + + /* + * In case of opaque color format bitdepth will be known + * with first ETB, buffers allocated already with 8 bit + * won't be sufficient for 10 bit + * calculate size considering 10-bit by default + * For 10-bit cases size =3D size * 1.25 + */ + frame_size *=3D 5; + frame_size /=3D 4; + + return ALIGN(frame_size, SZ_4K); +} + +static inline u32 hfi_buffer_bin_enc(u32 width, u32 height, + u32 work_mode, u32 lcu_size, + u32 num_vpp_pipes, u32 rc_type) +{ + u32 sao_bin_buffer_size, padded_bin_size, bitstream_size; + u32 total_bitbin_buffers, size_single_pipe, bitbin_size; + u32 aligned_height =3D ALIGN(height, lcu_size); + u32 aligned_width =3D ALIGN(width, lcu_size); + + bitstream_size =3D size_bin_bitstream_enc(width, height, rc_type); + bitstream_size =3D ALIGN(bitstream_size, 256); + + if (work_mode =3D=3D STAGE_2) { + total_bitbin_buffers =3D 3; + bitbin_size =3D bitstream_size * 17 / 10; + bitbin_size =3D ALIGN(bitbin_size, 256); + } else { + total_bitbin_buffers =3D 1; + bitstream_size =3D aligned_width * aligned_height * 3; + bitbin_size =3D ALIGN(bitstream_size, 256); + } + + if (num_vpp_pipes > 2) + size_single_pipe =3D bitbin_size / 2; + else + size_single_pipe =3D bitbin_size; + + size_single_pipe =3D ALIGN(size_single_pipe, 256); + sao_bin_buffer_size =3D (64 * (((width + 32) * (height + 32)) >> 10)) + 3= 84; + padded_bin_size =3D ALIGN(size_single_pipe, 256); + size_single_pipe =3D sao_bin_buffer_size + padded_bin_size; + size_single_pipe =3D ALIGN(size_single_pipe, 256); + bitbin_size =3D size_single_pipe * num_vpp_pipes; + + return ALIGN(bitbin_size, 256) * total_bitbin_buffers + 512; +} + +static u32 iris_vpu_enc_bin_size(struct iris_inst *inst) +{ + u32 num_vpp_pipes =3D inst->core->iris_platform_data->num_vpp_pipe; + u32 stage =3D inst->fw_caps[STAGE].value; + struct v4l2_format *f =3D inst->fmt_dst; + u32 height =3D f->fmt.pix_mp.height; + u32 width =3D f->fmt.pix_mp.width; + u32 lcu_size; + + if (inst->codec =3D=3D V4L2_PIX_FMT_HEVC) + lcu_size =3D 32; + else + lcu_size =3D 16; + + return hfi_buffer_bin_enc(width, height, stage, lcu_size, + num_vpp_pipes, inst->hfi_rc_type); +} + +static inline +u32 hfi_buffer_comv_enc(u32 frame_width, u32 frame_height, u32 lcu_size, + u32 num_recon, u32 standard) +{ + u32 height_in_lcus =3D ((frame_height) + (lcu_size) - 1) / (lcu_size); + u32 width_in_lcus =3D ((frame_width) + (lcu_size) - 1) / (lcu_size); + u32 num_lcu_in_frame =3D width_in_lcus * height_in_lcus; + u32 mb_height =3D ((frame_height) + 15) >> 4; + u32 mb_width =3D ((frame_width) + 15) >> 4; + u32 size_colloc_mv, size_colloc_rc; + + size_colloc_mv =3D (standard =3D=3D HFI_CODEC_ENCODE_HEVC) ? + (16 * ((num_lcu_in_frame << 2) + 32)) : + (3 * 16 * (width_in_lcus * height_in_lcus + 32)); + size_colloc_mv =3D ALIGN(size_colloc_mv, 256) * num_recon; + size_colloc_rc =3D (((mb_width + 7) >> 3) * 16 * 2 * mb_height); + size_colloc_rc =3D ALIGN(size_colloc_rc, 256) * HFI_MAX_COL_FRAME; + + return size_colloc_mv + size_colloc_rc; +} + +static u32 iris_vpu_enc_comv_size(struct iris_inst *inst) +{ + struct v4l2_format *f =3D inst->fmt_dst; + u32 height =3D f->fmt.pix_mp.height; + u32 width =3D f->fmt.pix_mp.width; + u32 num_recon =3D 1; + u32 lcu_size =3D 16; + + if (inst->codec =3D=3D V4L2_PIX_FMT_HEVC) { + lcu_size =3D 32; + return hfi_buffer_comv_enc(width, height, lcu_size, + num_recon + 1, HFI_CODEC_ENCODE_HEVC); + } + + return hfi_buffer_comv_enc(width, height, lcu_size, + num_recon + 1, HFI_CODEC_ENCODE_AVC); +} + +static inline +u32 size_frame_rc_buf_size(u32 standard, u32 frame_height_coded, + u32 num_vpp_pipes_enc) +{ + u32 size =3D 0; + + size =3D (standard =3D=3D HFI_CODEC_ENCODE_HEVC) ? + (256 + 16 * (14 + ((((frame_height_coded) >> 5) + 7) >> 3))) : + (256 + 16 * (14 + ((((frame_height_coded) >> 4) + 7) >> 3))); + size *=3D 11; + + if (num_vpp_pipes_enc > 1) + size =3D ALIGN(size, 256) * num_vpp_pipes_enc; + + return ALIGN(size, 512) * HFI_MAX_COL_FRAME; +} + +static inline +u32 size_enc_slice_info_buf(u32 num_lcu_in_frame) +{ + return ALIGN((256 + (num_lcu_in_frame << 4)), 256); +} + +static inline u32 enc_bitcnt_buf_size(u32 num_lcu_in_frame) +{ + return ALIGN((256 + (4 * (num_lcu_in_frame))), 256); +} + +static inline u32 enc_bitmap_buf_size(u32 num_lcu_in_frame) +{ + return ALIGN((256 + ((num_lcu_in_frame) >> 3)), 256); +} + +static inline u32 size_override_buf(u32 num_lcumb) +{ + return ALIGN(((16 * (((num_lcumb) + 7) >> 3))), 256) * 2; +} + +static inline u32 size_ir_buf(u32 num_lcu_in_frame) +{ + return ALIGN((((((num_lcu_in_frame) << 1) + 7) & (~7)) * 3), 256); +} + +static inline +u32 size_linebuff_data(bool is_ten_bit, u32 frame_width_coded) +{ + return is_ten_bit ? + (((((10 * (frame_width_coded) + 1024) + (256 - 1)) & + (~(256 - 1))) * 1) + + (((((10 * (frame_width_coded) + 1024) >> 1) + (256 - 1)) & + (~(256 - 1))) * 2)) : + (((((8 * (frame_width_coded) + 1024) + (256 - 1)) & + (~(256 - 1))) * 1) + + (((((8 * (frame_width_coded) + 1024) >> 1) + (256 - 1)) & + (~(256 - 1))) * 2)); +} + +static inline +u32 size_left_linebuff_ctrl(u32 standard, u32 frame_height_coded, + u32 num_vpp_pipes_enc) +{ + u32 size =3D 0; + + size =3D standard =3D=3D HFI_CODEC_ENCODE_HEVC ? + (((frame_height_coded) + + (32)) / 32 * 4 * 16) : + (((frame_height_coded) + 15) / 16 * 5 * 16); + + if ((num_vpp_pipes_enc) > 1) { + size +=3D 512; + size =3D ALIGN(size, 512) * + num_vpp_pipes_enc; + } + + return ALIGN(size, 256); +} + +static inline +u32 size_left_linebuff_recon_pix(bool is_ten_bit, u32 frame_height_coded, + u32 num_vpp_pipes_enc) +{ + return (((is_ten_bit + 1) * 2 * (frame_height_coded) + 256) + + (256 << (num_vpp_pipes_enc - 1)) - 1) & + (~((256 << (num_vpp_pipes_enc - 1)) - 1)) * 1; +} + +static inline +u32 size_top_linebuff_ctrl_fe(u32 frame_width_coded, u32 standard) +{ + return standard =3D=3D HFI_CODEC_ENCODE_HEVC ? + ALIGN((64 * ((frame_width_coded) >> 5)), 256) : + ALIGN((256 + 16 * ((frame_width_coded) >> 4)), 256); +} + +static inline +u32 size_left_linebuff_ctrl_fe(u32 frame_height_coded, u32 num_vpp_pipes_e= nc) +{ + return (((256 + 64 * ((frame_height_coded) >> 4)) + + (256 << (num_vpp_pipes_enc - 1)) - 1) & + (~((256 << (num_vpp_pipes_enc - 1)) - 1)) * 1) * + num_vpp_pipes_enc; +} + +static inline +u32 size_left_linebuff_metadata_recon_y(u32 frame_height_coded, + bool is_ten_bit, + u32 num_vpp_pipes_enc) +{ + return ALIGN(((256 + 64 * ((frame_height_coded) / + (8 * (is_ten_bit ? 4 : 8))))), 256) * num_vpp_pipes_enc; +} + +static inline +u32 size_left_linebuff_metadata_recon_uv(u32 frame_height_coded, + bool is_ten_bit, + u32 num_vpp_pipes_enc) +{ + return ALIGN(((256 + 64 * ((frame_height_coded) / + (4 * (is_ten_bit ? 4 : 8))))), 256) * num_vpp_pipes_enc; +} + +static inline +u32 size_linebuff_recon_pix(bool is_ten_bit, u32 frame_width_coded) +{ + return ALIGN(((is_ten_bit ? 3 : 2) * (frame_width_coded)), 256); +} + +static inline +u32 size_line_buf_ctrl(u32 frame_width_coded) +{ + return ALIGN(frame_width_coded, 256); +} + +static inline +u32 size_line_buf_ctrl_id2(u32 frame_width_coded) +{ + return ALIGN(frame_width_coded, 256); +} + +static inline u32 size_line_buf_sde(u32 frame_width_coded) +{ + return ALIGN((256 + (16 * ((frame_width_coded) >> 4))), 256); +} + +static inline +u32 size_vpss_line_buf(u32 num_vpp_pipes_enc, u32 frame_height_coded, + u32 frame_width_coded) +{ + return ALIGN(((((((8192) >> 2) << 5) * (num_vpp_pipes_enc)) + 64) + + (((((max_t(u32, (frame_width_coded), + (frame_height_coded)) + 3) >> 2) << 5) + 256) * 16)), 256); +} + +static inline +u32 size_top_line_buf_first_stg_sao(u32 frame_width_coded) +{ + return ALIGN((16 * ((frame_width_coded) >> 5)), 256); +} + +static inline +u32 size_enc_ref_buffer(u32 frame_width, u32 frame_height) +{ + u32 u_chroma_buffer_height =3D ALIGN(frame_height >> 1, 32); + u32 u_buffer_height =3D ALIGN(frame_height, 32); + u32 u_buffer_width =3D ALIGN(frame_width, 32); + + return (u_buffer_height + u_chroma_buffer_height) * u_buffer_width; +} + +static inline +u32 size_enc_ten_bit_ref_buffer(u32 frame_width, u32 frame_height) +{ + u32 ref_luma_stride_in_bytes =3D ((frame_width + SYSTEM_LAL_TILE10 - 1) /= SYSTEM_LAL_TILE10) * + SYSTEM_LAL_TILE10; + u32 ref_buf_height =3D (frame_height + (32 - 1)) & (~(32 - 1)); + u32 u_ref_stride, luma_size; + u32 ref_chrm_height_in_bytes; + u32 chroma_size; + + u_ref_stride =3D 4 * (ref_luma_stride_in_bytes / 3); + u_ref_stride =3D (u_ref_stride + (128 - 1)) & (~(128 - 1)); + luma_size =3D ref_buf_height * u_ref_stride; + luma_size =3D (luma_size + (4096 - 1)) & (~(4096 - 1)); + + ref_chrm_height_in_bytes =3D (((frame_height + 1) >> 1) + (32 - 1)) & (~(= 32 - 1)); + chroma_size =3D u_ref_stride * ref_chrm_height_in_bytes; + chroma_size =3D (chroma_size + (4096 - 1)) & (~(4096 - 1)); + + return luma_size + chroma_size; +} + +static inline +u32 hfi_ubwc_calc_metadata_plane_stride(u32 frame_width, + u32 metadata_stride_multiple, + u32 tile_width_in_pels) +{ + return ALIGN(((frame_width + (tile_width_in_pels - 1)) / tile_width_in_pe= ls), + metadata_stride_multiple); +} + +static inline +u32 hfi_ubwc_metadata_plane_bufheight(u32 frame_height, + u32 metadata_height_multiple, + u32 tile_height_in_pels) +{ + return ALIGN(((frame_height + (tile_height_in_pels - 1)) / tile_height_in= _pels), + metadata_height_multiple); +} + +static inline +u32 hfi_ubwc_metadata_plane_buffer_size(u32 _metadata_tride, u32 _metadata= _buf_height) +{ + return ALIGN(_metadata_tride * _metadata_buf_height, 4096); +} + +static inline +u32 hfi_buffer_non_comv_enc(u32 frame_width, u32 frame_height, + u32 num_vpp_pipes_enc, u32 lcu_size, u32 standard) +{ + u32 height_in_lcus =3D ((frame_height) + (lcu_size) - 1) / (lcu_size); + u32 width_in_lcus =3D ((frame_width) + (lcu_size) - 1) / (lcu_size); + u32 num_lcu_in_frame =3D width_in_lcus * height_in_lcus; + u32 frame_height_coded =3D height_in_lcus * (lcu_size); + u32 frame_width_coded =3D width_in_lcus * (lcu_size); + u32 num_lcumb, frame_rc_buf_size; + + num_lcumb =3D (frame_height_coded / lcu_size) * + ((frame_width_coded + lcu_size * 8) / lcu_size); + frame_rc_buf_size =3D size_frame_rc_buf_size(standard, frame_height_coded, + num_vpp_pipes_enc); + return size_enc_slice_info_buf(num_lcu_in_frame) + + SIZE_SLICE_CMD_BUFFER + + SIZE_SPS_PPS_SLICE_HDR + + frame_rc_buf_size + + enc_bitcnt_buf_size(num_lcu_in_frame) + + enc_bitmap_buf_size(num_lcu_in_frame) + + SIZE_BSE_SLICE_CMD_BUF + + SIZE_LAMBDA_LUT + + size_override_buf(num_lcumb) + + size_ir_buf(num_lcu_in_frame); +} + +static u32 iris_vpu_enc_non_comv_size(struct iris_inst *inst) +{ + u32 num_vpp_pipes =3D inst->core->iris_platform_data->num_vpp_pipe; + struct v4l2_format *f =3D inst->fmt_dst; + u32 height =3D f->fmt.pix_mp.height; + u32 width =3D f->fmt.pix_mp.width; + u32 lcu_size =3D 16; + + if (inst->codec =3D=3D V4L2_PIX_FMT_HEVC) { + lcu_size =3D 32; + return hfi_buffer_non_comv_enc(width, height, num_vpp_pipes, + lcu_size, HFI_CODEC_ENCODE_HEVC); + } + + return hfi_buffer_non_comv_enc(width, height, num_vpp_pipes, + lcu_size, HFI_CODEC_ENCODE_AVC); +} + +static inline +u32 hfi_buffer_line_enc(u32 frame_width, u32 frame_height, bool is_ten_bit, + u32 num_vpp_pipes_enc, u32 lcu_size, u32 standard) +{ + u32 width_in_lcus =3D ((frame_width) + (lcu_size) - 1) / (lcu_size); + u32 height_in_lcus =3D ((frame_height) + (lcu_size) - 1) / (lcu_size); + u32 frame_height_coded =3D height_in_lcus * (lcu_size); + u32 frame_width_coded =3D width_in_lcus * (lcu_size); + u32 line_buff_data_size, left_line_buff_ctrl_size; + u32 left_line_buff_metadata_recon__uv__size; + u32 left_line_buff_metadata_recon__y__size; + u32 left_line_buff_recon_pix_size; + u32 top_line_buff_ctrl_fe_size; + u32 line_buff_recon_pix_size; + + line_buff_data_size =3D size_linebuff_data(is_ten_bit, frame_width_coded); + left_line_buff_ctrl_size =3D + size_left_linebuff_ctrl(standard, frame_height_coded, num_vpp_pipes_enc); + left_line_buff_recon_pix_size =3D + size_left_linebuff_recon_pix(is_ten_bit, frame_height_coded, + num_vpp_pipes_enc); + top_line_buff_ctrl_fe_size =3D + size_top_linebuff_ctrl_fe(frame_width_coded, standard); + left_line_buff_metadata_recon__y__size =3D + size_left_linebuff_metadata_recon_y(frame_height_coded, is_ten_bit, + num_vpp_pipes_enc); + left_line_buff_metadata_recon__uv__size =3D + size_left_linebuff_metadata_recon_uv(frame_height_coded, is_ten_bit, + num_vpp_pipes_enc); + line_buff_recon_pix_size =3D size_linebuff_recon_pix(is_ten_bit, frame_wi= dth_coded); + + return size_line_buf_ctrl(frame_width_coded) + + size_line_buf_ctrl_id2(frame_width_coded) + + line_buff_data_size + + left_line_buff_ctrl_size + + left_line_buff_recon_pix_size + + top_line_buff_ctrl_fe_size + + left_line_buff_metadata_recon__y__size + + left_line_buff_metadata_recon__uv__size + + line_buff_recon_pix_size + + size_left_linebuff_ctrl_fe(frame_height_coded, num_vpp_pipes_enc) + + size_line_buf_sde(frame_width_coded) + + size_vpss_line_buf(num_vpp_pipes_enc, frame_height_coded, frame_width_co= ded) + + size_top_line_buf_first_stg_sao(frame_width_coded); +} + +static u32 iris_vpu_enc_line_size(struct iris_inst *inst) +{ + u32 num_vpp_pipes =3D inst->core->iris_platform_data->num_vpp_pipe; + struct v4l2_format *f =3D inst->fmt_dst; + u32 height =3D f->fmt.pix_mp.height; + u32 width =3D f->fmt.pix_mp.width; + u32 lcu_size =3D 16; + + if (inst->codec =3D=3D V4L2_PIX_FMT_HEVC) { + lcu_size =3D 32; + return hfi_buffer_line_enc(width, height, 0, num_vpp_pipes, + lcu_size, HFI_CODEC_ENCODE_HEVC); + } + + return hfi_buffer_line_enc(width, height, 0, num_vpp_pipes, + lcu_size, HFI_CODEC_ENCODE_AVC); +} + +static inline +u32 hfi_buffer_dpb_enc(u32 frame_width, u32 frame_height, bool is_ten_bit) +{ + u32 metadata_stride, metadata_buf_height, meta_size_y, meta_size_c; + u32 ten_bit_ref_buf_size =3D 0, ref_buf_size =3D 0; + u32 size; + + if (!is_ten_bit) { + ref_buf_size =3D size_enc_ref_buffer(frame_width, frame_height); + metadata_stride =3D + hfi_ubwc_calc_metadata_plane_stride(frame_width, 64, + HFI_COL_FMT_NV12C_Y_TILE_WIDTH); + metadata_buf_height =3D + hfi_ubwc_metadata_plane_bufheight(frame_height, 16, + HFI_COL_FMT_NV12C_Y_TILE_HEIGHT); + meta_size_y =3D + hfi_ubwc_metadata_plane_buffer_size(metadata_stride, metadata_buf_heigh= t); + meta_size_c =3D + hfi_ubwc_metadata_plane_buffer_size(metadata_stride, metadata_buf_heigh= t); + size =3D ref_buf_size + meta_size_y + meta_size_c; + } else { + ten_bit_ref_buf_size =3D size_enc_ten_bit_ref_buffer(frame_width, frame_= height); + metadata_stride =3D + hfi_ubwc_calc_metadata_plane_stride(frame_width, + IRIS_METADATA_STRIDE_MULTIPLE, + HFI_COL_FMT_TP10C_Y_TILE_WIDTH); + metadata_buf_height =3D + hfi_ubwc_metadata_plane_bufheight(frame_height, + IRIS_METADATA_HEIGHT_MULTIPLE, + HFI_COL_FMT_TP10C_Y_TILE_HEIGHT); + meta_size_y =3D + hfi_ubwc_metadata_plane_buffer_size(metadata_stride, metadata_buf_heigh= t); + meta_size_c =3D + hfi_ubwc_metadata_plane_buffer_size(metadata_stride, metadata_buf_heigh= t); + size =3D ten_bit_ref_buf_size + meta_size_y + meta_size_c; + } + + return size; +} + +static u32 iris_vpu_enc_arp_size(struct iris_inst *inst) +{ + return HFI_BUFFER_ARP_ENC; +} + +inline bool is_scaling_enabled(struct iris_inst *inst) +{ + return inst->crop.left !=3D inst->compose.left || + inst->crop.top !=3D inst->compose.top || + inst->crop.width !=3D inst->compose.width || + inst->crop.height !=3D inst->compose.height; +} + +static inline +u32 hfi_buffer_vpss_enc(u32 dswidth, u32 dsheight, bool ds_enable, + u32 blur, bool is_ten_bit) +{ + if (ds_enable || blur) + return hfi_buffer_dpb_enc(dswidth, dsheight, is_ten_bit); + + return 0; +} + +static inline u32 hfi_buffer_scratch1_enc(u32 frame_width, u32 frame_heigh= t, + u32 lcu_size, u32 num_ref, + bool ten_bit, u32 num_vpp_pipes, + bool is_h265) +{ + u32 line_buf_ctrl_size, line_buf_data_size, leftline_buf_ctrl_size; + u32 line_buf_sde_size, sps_pps_slice_hdr, topline_buf_ctrl_size_FE; + u32 leftline_buf_ctrl_size_FE, line_buf_recon_pix_size; + u32 leftline_buf_recon_pix_size, lambda_lut_size, override_buffer_size; + u32 col_mv_buf_size, vpp_reg_buffer_size, ir_buffer_size; + u32 vpss_line_buf, leftline_buf_meta_recony, h265e_colrcbuf_size; + u32 h265e_framerc_bufsize, h265e_lcubitcnt_bufsize; + u32 h265e_lcubitmap_bufsize, se_stats_bufsize; + u32 bse_reg_buffer_size, bse_slice_cmd_buffer_size, slice_info_bufsize; + u32 line_buf_ctrl_size_buffid2, slice_cmd_buffer_size; + u32 width_lcu_num, height_lcu_num, width_coded, height_coded; + u32 frame_num_lcu, linebuf_meta_recon_uv, topline_bufsize_fe_1stg_sao; + u32 vpss_line_buffer_size_1; + u32 bit_depth, num_lcu_mb; + + width_lcu_num =3D (frame_width + lcu_size - 1) / lcu_size; + height_lcu_num =3D (frame_height + lcu_size - 1) / lcu_size; + frame_num_lcu =3D width_lcu_num * height_lcu_num; + width_coded =3D width_lcu_num * lcu_size; + height_coded =3D height_lcu_num * lcu_size; + num_lcu_mb =3D (height_coded / lcu_size) * + ((width_coded + lcu_size * 8) / lcu_size); + slice_info_bufsize =3D 256 + (frame_num_lcu << 4); + slice_info_bufsize =3D ALIGN(slice_info_bufsize, 256); + line_buf_ctrl_size =3D ALIGN(width_coded, 256); + line_buf_ctrl_size_buffid2 =3D ALIGN(width_coded, 256); + + bit_depth =3D ten_bit ? 10 : 8; + line_buf_data_size =3D + (((((bit_depth * width_coded + 1024) + (256 - 1)) & + (~(256 - 1))) * 1) + + (((((bit_depth * width_coded + 1024) >> 1) + (256 - 1)) & + (~(256 - 1))) * 2)); + + leftline_buf_ctrl_size =3D is_h265 ? ((height_coded + 32) / 32 * 4 * 16) : + ((height_coded + 15) / 16 * 5 * 16); + + if (num_vpp_pipes > 1) { + leftline_buf_ctrl_size +=3D 512; + leftline_buf_ctrl_size =3D + ALIGN(leftline_buf_ctrl_size, 512) * num_vpp_pipes; + } + + leftline_buf_ctrl_size =3D ALIGN(leftline_buf_ctrl_size, 256); + leftline_buf_recon_pix_size =3D + (((ten_bit + 1) * 2 * (height_coded) + 256) + + (256 << (num_vpp_pipes - 1)) - 1) & + (~((256 << (num_vpp_pipes - 1)) - 1)) * 1; + + topline_buf_ctrl_size_FE =3D is_h265 ? (64 * (width_coded >> 5)) : + (256 + 16 * (width_coded >> 4)); + topline_buf_ctrl_size_FE =3D ALIGN(topline_buf_ctrl_size_FE, 256); + leftline_buf_ctrl_size_FE =3D + (((256 + 64 * (height_coded >> 4)) + + (256 << (num_vpp_pipes - 1)) - 1) & + (~((256 << (num_vpp_pipes - 1)) - 1)) * 1) * + num_vpp_pipes; + leftline_buf_meta_recony =3D + (256 + 64 * ((height_coded) / (8 * (ten_bit ? 4 : 8)))); + leftline_buf_meta_recony =3D ALIGN(leftline_buf_meta_recony, 256); + leftline_buf_meta_recony =3D leftline_buf_meta_recony * num_vpp_pipes; + linebuf_meta_recon_uv =3D + (256 + 64 * ((height_coded) / (4 * (ten_bit ? 4 : 8)))); + linebuf_meta_recon_uv =3D ALIGN(linebuf_meta_recon_uv, 256); + linebuf_meta_recon_uv =3D linebuf_meta_recon_uv * num_vpp_pipes; + line_buf_recon_pix_size =3D ((ten_bit ? 3 : 2) * width_coded); + line_buf_recon_pix_size =3D ALIGN(line_buf_recon_pix_size, 256); + slice_cmd_buffer_size =3D ALIGN(20480, 256); + sps_pps_slice_hdr =3D 2048 + 4096; + col_mv_buf_size =3D + is_h265 ? (16 * ((frame_num_lcu << 2) + 32)) : + (3 * 16 * (width_lcu_num * height_lcu_num + 32)); + col_mv_buf_size =3D ALIGN(col_mv_buf_size, 256) * (num_ref + 1); + h265e_colrcbuf_size =3D + (((width_lcu_num + 7) >> 3) * 16 * 2 * height_lcu_num); + if (num_vpp_pipes > 1) + h265e_colrcbuf_size =3D + ALIGN(h265e_colrcbuf_size, 256) * num_vpp_pipes; + + h265e_colrcbuf_size =3D + ALIGN(h265e_colrcbuf_size, 256) * HFI_MAX_COL_FRAME; + h265e_framerc_bufsize =3D + (is_h265) ? + (256 + 16 * (14 + (((height_coded >> 5) + 7) >> 3))) : + (256 + 16 * (14 + (((height_coded >> 4) + 7) >> 3))); + h265e_framerc_bufsize *=3D 6; + if (num_vpp_pipes > 1) + h265e_framerc_bufsize =3D + ALIGN(h265e_framerc_bufsize, 256) * num_vpp_pipes; + + h265e_framerc_bufsize =3D + ALIGN(h265e_framerc_bufsize, 512) * HFI_MAX_COL_FRAME; + h265e_lcubitcnt_bufsize =3D 256 + 4 * frame_num_lcu; + h265e_lcubitcnt_bufsize =3D ALIGN(h265e_lcubitcnt_bufsize, 256); + h265e_lcubitmap_bufsize =3D 256 + (frame_num_lcu >> 3); + h265e_lcubitmap_bufsize =3D ALIGN(h265e_lcubitmap_bufsize, 256); + line_buf_sde_size =3D 256 + 16 * (width_coded >> 4); + line_buf_sde_size =3D ALIGN(line_buf_sde_size, 256); + if ((width_coded * height_coded) > (4096 * 2160)) + se_stats_bufsize =3D 0; + else if ((width_coded * height_coded) > (1920 * 1088)) + se_stats_bufsize =3D (40 * 4 * frame_num_lcu + 256 + 256); + else + se_stats_bufsize =3D (1024 * frame_num_lcu + 256 + 256); + + se_stats_bufsize =3D ALIGN(se_stats_bufsize, 256) * 2; + bse_slice_cmd_buffer_size =3D (((8192 << 2) + 7) & (~7)) * 6; + bse_reg_buffer_size =3D (((512 << 3) + 7) & (~7)) * 4; + vpp_reg_buffer_size =3D (((2048 << 3) + 31) & (~31)) * 10; + lambda_lut_size =3D 256 * 11; + override_buffer_size =3D 16 * ((num_lcu_mb + 7) >> 3); + override_buffer_size =3D ALIGN(override_buffer_size, 256) * 2; + ir_buffer_size =3D (((frame_num_lcu << 1) + 7) & (~7)) * 3; + vpss_line_buffer_size_1 =3D (((8192 >> 2) << 5) * num_vpp_pipes) + 64; + vpss_line_buf =3D + (((((max(width_coded, height_coded) + 3) >> 2) << 5) + 256) * + 16) + + vpss_line_buffer_size_1; + topline_bufsize_fe_1stg_sao =3D 16 * (width_coded >> 5); + topline_bufsize_fe_1stg_sao =3D ALIGN(topline_bufsize_fe_1stg_sao, 256); + + return line_buf_ctrl_size + line_buf_data_size + + line_buf_ctrl_size_buffid2 + leftline_buf_ctrl_size + + vpss_line_buf + col_mv_buf_size + topline_buf_ctrl_size_FE + + leftline_buf_ctrl_size_FE + line_buf_recon_pix_size + + leftline_buf_recon_pix_size + leftline_buf_meta_recony + + linebuf_meta_recon_uv + h265e_colrcbuf_size + + h265e_framerc_bufsize + h265e_lcubitcnt_bufsize + + h265e_lcubitmap_bufsize + line_buf_sde_size + + topline_bufsize_fe_1stg_sao + override_buffer_size + + bse_reg_buffer_size + vpp_reg_buffer_size + sps_pps_slice_hdr + + slice_cmd_buffer_size + bse_slice_cmd_buffer_size + + ir_buffer_size + slice_info_bufsize + lambda_lut_size + + se_stats_bufsize + 1024; +} + +static u32 iris_vpu_enc_scratch1_size(struct iris_inst *inst) +{ + u32 num_vpp_pipes =3D inst->core->iris_platform_data->num_vpp_pipe; + struct v4l2_format *f =3D inst->fmt_dst; + u32 frame_height =3D f->fmt.pix_mp.height; + u32 frame_width =3D f->fmt.pix_mp.width; + u32 num_ref =3D 1; + u32 lcu_size; + bool is_h265; + + if (inst->codec =3D=3D V4L2_PIX_FMT_H264) { + lcu_size =3D 16; + is_h265 =3D false; + } else if (inst->codec =3D=3D V4L2_PIX_FMT_HEVC) { + lcu_size =3D 32; + is_h265 =3D true; + } else { + return 0; + } + + return hfi_buffer_scratch1_enc(frame_width, frame_height, lcu_size, + num_ref, false, num_vpp_pipes, is_h265); +} + +static inline u32 ubwc_metadata_plane_stride(u32 width, + u32 metadata_stride_multi, + u32 tile_width_pels) +{ + return ALIGN(((width + (tile_width_pels - 1)) / tile_width_pels), + metadata_stride_multi); +} + +static inline u32 ubwc_metadata_plane_bufheight(u32 height, + u32 metadata_height_multi, + u32 tile_height_pels) +{ + return ALIGN(((height + (tile_height_pels - 1)) / tile_height_pels), + metadata_height_multi); +} + +static inline u32 ubwc_metadata_plane_buffer_size(u32 metadata_stride, + u32 metadata_buf_height) +{ + return ALIGN(metadata_stride * metadata_buf_height, SZ_4K); +} + +static inline u32 hfi_buffer_scratch2_enc(u32 frame_width, u32 frame_heigh= t, + u32 num_ref, bool ten_bit) +{ + u32 aligned_width, aligned_height, chroma_height, ref_buf_height; + u32 metadata_stride, meta_buf_height, meta_size_y, meta_size_c; + u32 ref_luma_stride_bytes, ref_chroma_height_bytes; + u32 ref_buf_size, ref_stride; + u32 luma_size, chroma_size; + u32 size; + + if (!ten_bit) { + aligned_height =3D ALIGN(frame_height, 32); + chroma_height =3D frame_height >> 1; + chroma_height =3D ALIGN(chroma_height, 32); + aligned_width =3D ALIGN(frame_width, 128); + metadata_stride =3D + ubwc_metadata_plane_stride(frame_width, 64, 32); + meta_buf_height =3D + ubwc_metadata_plane_bufheight(frame_height, 16, 8); + meta_size_y =3D ubwc_metadata_plane_buffer_size(metadata_stride, + meta_buf_height); + meta_size_c =3D ubwc_metadata_plane_buffer_size(metadata_stride, + meta_buf_height); + size =3D (aligned_height + chroma_height) * aligned_width + + meta_size_y + meta_size_c; + size =3D (size * (num_ref + 3)) + 4096; + } else { + ref_buf_height =3D (frame_height + (32 - 1)) & (~(32 - 1)); + ref_luma_stride_bytes =3D ((frame_width + 192 - 1) / 192) * 192; + ref_stride =3D 4 * (ref_luma_stride_bytes / 3); + ref_stride =3D (ref_stride + (128 - 1)) & (~(128 - 1)); + luma_size =3D ref_buf_height * ref_stride; + ref_chroma_height_bytes =3D + (((frame_height + 1) >> 1) + (32 - 1)) & (~(32 - 1)); + chroma_size =3D ref_stride * ref_chroma_height_bytes; + luma_size =3D (luma_size + (SZ_4K - 1)) & (~(SZ_4K - 1)); + chroma_size =3D (chroma_size + (SZ_4K - 1)) & (~(SZ_4K - 1)); + ref_buf_size =3D luma_size + chroma_size; + metadata_stride =3D + ubwc_metadata_plane_stride(frame_width, 64, 48); + meta_buf_height =3D + ubwc_metadata_plane_bufheight(frame_height, 16, 4); + meta_size_y =3D ubwc_metadata_plane_buffer_size(metadata_stride, + meta_buf_height); + meta_size_c =3D ubwc_metadata_plane_buffer_size(metadata_stride, + meta_buf_height); + size =3D ref_buf_size + meta_size_y + meta_size_c; + size =3D (size * (num_ref + 3)) + 4096; + } + + return size; +} + +static u32 iris_vpu_enc_scratch2_size(struct iris_inst *inst) +{ + struct v4l2_format *f =3D inst->fmt_dst; + u32 frame_width =3D f->fmt.pix_mp.width; + u32 frame_height =3D f->fmt.pix_mp.height; + u32 num_ref =3D 1; + + return hfi_buffer_scratch2_enc(frame_width, frame_height, num_ref, + false); +} + +static u32 iris_vpu_enc_vpss_size(struct iris_inst *inst) +{ + u32 ds_enable =3D is_scaling_enabled(inst); + struct v4l2_format *f =3D inst->fmt_dst; + u32 height =3D f->fmt.pix_mp.height; + u32 width =3D f->fmt.pix_mp.width; + + return hfi_buffer_vpss_enc(width, height, ds_enable, 0, 0); +} + static int output_min_count(struct iris_inst *inst) { int output_min_count =3D 4; @@ -573,8 +1387,8 @@ struct iris_vpu_buf_type_handle { =20 int iris_vpu_buf_size(struct iris_inst *inst, enum iris_buffer_type buffer= _type) { - const struct iris_vpu_buf_type_handle *buf_type_handle_arr; - u32 size =3D 0, buf_type_handle_size, i; + const struct iris_vpu_buf_type_handle *buf_type_handle_arr =3D NULL; + u32 size =3D 0, buf_type_handle_size =3D 0, i; =20 static const struct iris_vpu_buf_type_handle dec_internal_buf_type_handle= [] =3D { {BUF_BIN, iris_vpu_dec_bin_size }, @@ -586,8 +1400,24 @@ int iris_vpu_buf_size(struct iris_inst *inst, enum ir= is_buffer_type buffer_type) {BUF_SCRATCH_1, iris_vpu_dec_scratch1_size }, }; =20 - buf_type_handle_size =3D ARRAY_SIZE(dec_internal_buf_type_handle); - buf_type_handle_arr =3D dec_internal_buf_type_handle; + static const struct iris_vpu_buf_type_handle enc_internal_buf_type_handle= [] =3D { + {BUF_BIN, iris_vpu_enc_bin_size }, + {BUF_COMV, iris_vpu_enc_comv_size }, + {BUF_NON_COMV, iris_vpu_enc_non_comv_size }, + {BUF_LINE, iris_vpu_enc_line_size }, + {BUF_ARP, iris_vpu_enc_arp_size }, + {BUF_VPSS, iris_vpu_enc_vpss_size }, + {BUF_SCRATCH_1, iris_vpu_enc_scratch1_size }, + {BUF_SCRATCH_2, iris_vpu_enc_scratch2_size }, + }; + + if (inst->domain =3D=3D DECODER) { + buf_type_handle_size =3D ARRAY_SIZE(dec_internal_buf_type_handle); + buf_type_handle_arr =3D dec_internal_buf_type_handle; + } else if (inst->domain =3D=3D ENCODER) { + buf_type_handle_size =3D ARRAY_SIZE(enc_internal_buf_type_handle); + buf_type_handle_arr =3D enc_internal_buf_type_handle; + } =20 for (i =3D 0; i < buf_type_handle_size; i++) { if (buf_type_handle_arr[i].type =3D=3D buffer_type) { @@ -639,6 +1469,9 @@ int iris_vpu_buf_count(struct iris_inst *inst, enum ir= is_buffer_type buffer_type case BUF_PERSIST: return internal_buffer_count(inst, buffer_type); case BUF_SCRATCH_1: + case BUF_SCRATCH_2: + case BUF_VPSS: + case BUF_ARP: return 1; /* internal buffer count needed by firmware is 1 */ case BUF_DPB: return iris_vpu_dpb_count(inst); diff --git a/drivers/media/platform/qcom/iris/iris_vpu_buffer.h b/drivers/m= edia/platform/qcom/iris/iris_vpu_buffer.h index ee95fd20b794c52d0070c93224bd4ee5e4e180d5..1ff1b07ecbaa85345ca948affeb= 1c4a1c55e36b0 100644 --- a/drivers/media/platform/qcom/iris/iris_vpu_buffer.h +++ b/drivers/media/platform/qcom/iris/iris_vpu_buffer.h @@ -80,6 +80,26 @@ struct iris_inst; #define MAX_PE_NBR_DATA_LCU64_LINE_BUFFER_SIZE 384 #define MAX_FE_NBR_DATA_LUMA_LINE_BUFFER_SIZE 640 =20 +#define SIZE_SLICE_CMD_BUFFER (ALIGN(20480, 256)) +#define SIZE_SPS_PPS_SLICE_HDR (2048 + 4096) +#define SIZE_BSE_SLICE_CMD_BUF ((((8192 << 2) + 7) & (~7)) * 3) +#define SIZE_LAMBDA_LUT (256 * 11) + +#define HFI_COL_FMT_NV12C_Y_TILE_HEIGHT (8) +#define HFI_COL_FMT_NV12C_Y_TILE_WIDTH (32) +#define HFI_COL_FMT_TP10C_Y_TILE_HEIGHT (4) +#define HFI_COL_FMT_TP10C_Y_TILE_WIDTH (48) + +#define IRIS_METADATA_STRIDE_MULTIPLE 64 +#define IRIS_METADATA_HEIGHT_MULTIPLE 16 + +#define HFI_BUFFER_ARP_ENC 204800 + +#define MAX_WIDTH 4096 +#define MAX_HEIGHT 2304 +#define NUM_MBS_4K (DIV_ROUND_UP(MAX_WIDTH, 16) * DIV_ROUND_UP(MAX_HEIGHT,= 16)) +#define NUM_MBS_720P (((ALIGN(1280, 16)) >> 4) * ((ALIGN(736, 16)) >> 4)) + static inline u32 size_h264d_lb_fe_top_data(u32 frame_width) { return MAX_FE_NBR_DATA_LUMA_LINE_BUFFER_SIZE * ALIGN(frame_width, 16) * 3; --=20 2.34.1 From nobody Tue Oct 7 22:51:46 2025 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 DEA812EF28C; Fri, 4 Jul 2025 07:54:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615695; cv=none; b=LUt3nHgVjvbiqlpWv0g5p3ltAN/oy8RuWZLwFCDYRvb1apRHNmjFGFLnsd+q7QPIvq27jKN2BRuZiDm2+boDfAUDsvSs1RPc6MvOnEVkHrAymgdJJq87HBtvJsKuoRg9AcqWM1mwxCQMfcKhGC+1HOxaZvn+8LKFAAMXQBHOMIg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615695; c=relaxed/simple; bh=etTcqf8MysOnqAflC3+Awa0DzIMVJMC3JmqjtWPH6Fc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=Tj9FZ19ngHQ+dQr8J8fPrHtqEx+9G2gXsqctvTRzSgZRqtXsHs+t1ZbhnnjM9pqn25uM/czUSN+WveNwnbkCUQFgDTd0jtyoaKl8YRyPvLVZ9kvBPw2N+ZrM6TOoHfnYXbMMZY48hk2AelP0qXcDBBrE6ZNcmny24dvE0kLx8WI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=HRKQXnJa; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="HRKQXnJa" Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56448PbL028446; Fri, 4 Jul 2025 07:54:45 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= ygFk/STMJfHMCsEIh8IC1oFraVn7dkNsnz37JBsIfeE=; b=HRKQXnJafmxNup77 wkFhZixqyHQjEm1CLP3fr7UCsxMkN1Ip5OFYMJ0nKwKXcfiLIi4pwLePLYRQI9qs qJyJgmAcsOqRr8xW1Ml73CdbqHXbawDdD6E45es4HubN6q+/rhVeFAXRcFJH2Fpn +XbYcScaC5MafNN844Z1aNtCgacz94QCM0yzr9pXUSCVKwik6m9xnrNsQIZWCe5g hNdMYvuru/pxm8cGq2fFKtbsssrZliXyF3PIn8iLkZf4rfLvLW8WArjvqu8I8nzl 966um/sRPtLoJZEqrV5uljirnYBPAmPgn/JBc3nM0ouCibBJ4jU6a1XZA5cC2knG IfOp/Q== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 47j7bw34yr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Jul 2025 07:54:45 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA02.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 5647sigE026619 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 4 Jul 2025 07:54:44 GMT Received: from hu-dikshita-hyd.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Fri, 4 Jul 2025 00:54:41 -0700 From: Dikshita Agarwal Date: Fri, 4 Jul 2025 13:23:24 +0530 Subject: [PATCH 24/25] media: iris: Add support for buffer management ioctls for encoder device Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20250704-iris-video-encoder-v1-24-b6ce24e273cf@quicinc.com> References: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> In-Reply-To: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> To: Vikash Garodia , Abhinav Kumar , Bryan O'Donoghue , Mauro Carvalho Chehab , Hans Verkuil , Stefan Schmidt , "Vedang Nagar" CC: , , , Dikshita Agarwal X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1751615599; l=21452; i=quic_dikshita@quicinc.com; s=20240917; h=from:subject:message-id; bh=etTcqf8MysOnqAflC3+Awa0DzIMVJMC3JmqjtWPH6Fc=; b=13fqKQGY+JJ0W/EgTSvExdkxHpq+KYhu0R71EKiXkgE3B11GtjHg3TPqztxIDfgwQiDW11Qbs eGeV69cFnZrDU+FUev7aH+2t4f8+MUsCn+RbhrO1koowFecG2Rqi9t2 X-Developer-Key: i=quic_dikshita@quicinc.com; a=ed25519; pk=EEvKY6Ar1OI5SWf44FJ1Ebo1KuQEVbbf5UNPO+UHVhM= X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: DGDiNFdMzWt4oqOquAx2s-bel_vvCkDy X-Authority-Analysis: v=2.4 cv=RJCzH5i+ c=1 sm=1 tr=0 ts=686788c5 cx=c_pps a=JYp8KDb2vCoCEuGobkYCKw==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=GEpy-HfZoHoA:10 a=IkcTkHD0fZMA:10 a=Wb1JkmetP80A:10 a=COk6AnOGAAAA:8 a=uu7d9NcAH6ORf4h6WngA:9 a=QEXdDO2ut3YA:10 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-ORIG-GUID: DGDiNFdMzWt4oqOquAx2s-bel_vvCkDy X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzA0MDA2MCBTYWx0ZWRfX+yc50Lc9IrDV Pz9aqqC3s4nyL0rOMJOJij/dAuaVFBuI7X+IpDtdz37DtgY8wolqqBKqDcb/3RAFBbU06uYNrO3 14bKY9Go69oKGoBuXIG3QQVPOD/4u2utu5oJW9CH7NVLsDkWixVKYXDwrsyWMbgN9UnQ/R+wzFI PL75606GpFpFcq3jT8/iix1pvV1wKZUXGBSlnmZ7SjvmNCmHe4uJgJfjjWVcsuTM3+l1KXZnaWJ gK9o+6RY6kvJPU1i2uJCKIABDmAkgabt60oBsK3vRi5yEzcLMXG/munBWsaymd7KL1c0tj/xdl4 CBAXKw+1qjRmWtR9Xl2gHdanuv1TjCfZfaw6Y95S4SS2cLym4R+N36zwQXtt3BQVPwxumoavAxz dqwfuCPTi2NMEPnASvIDHHetvCYjbQr1pU9rwS8OcgimXs9ZqC3j/5BAHVvonbW/10U3R58J X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-04_03,2025-07-02_04,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 impostorscore=0 priorityscore=1501 mlxlogscore=999 adultscore=0 malwarescore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 phishscore=0 bulkscore=0 suspectscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507040060 Implement support for queuing and dequeuing input and output buffers for the encoder video device using the appropriate V4L2 buffer management ioctls. This enables userspace applications to manage streaming buffers required for encoding operations. Signed-off-by: Dikshita Agarwal Tested-by: Vikash Garodia # X1E80100 --- drivers/media/platform/qcom/iris/iris_common.c | 37 +++++++++++++++ drivers/media/platform/qcom/iris/iris_common.h | 2 + .../platform/qcom/iris/iris_hfi_gen1_command.c | 53 +++++++++++++++---= ---- .../platform/qcom/iris/iris_hfi_gen1_defines.h | 37 +++++++++++++++ .../platform/qcom/iris/iris_hfi_gen1_response.c | 45 +++++++++++++----- .../platform/qcom/iris/iris_hfi_gen2_command.c | 23 ++++++---- .../platform/qcom/iris/iris_hfi_gen2_response.c | 22 ++++++--- drivers/media/platform/qcom/iris/iris_vb2.c | 5 +- drivers/media/platform/qcom/iris/iris_vdec.c | 41 +---------------- drivers/media/platform/qcom/iris/iris_venc.c | 26 +++++++++++ drivers/media/platform/qcom/iris/iris_venc.h | 1 + drivers/media/platform/qcom/iris/iris_vidc.c | 8 ++++ 12 files changed, 218 insertions(+), 82 deletions(-) diff --git a/drivers/media/platform/qcom/iris/iris_common.c b/drivers/media= /platform/qcom/iris/iris_common.c index d6a9271bcec77f142919070bf0566d0cf8a39562..73547e8edcba0f28a6969d40388= 46cc987b6e271 100644 --- a/drivers/media/platform/qcom/iris/iris_common.c +++ b/drivers/media/platform/qcom/iris/iris_common.c @@ -10,6 +10,43 @@ #include "iris_instance.h" #include "iris_power.h" =20 +int iris_vb2_buffer_to_driver(struct vb2_buffer *vb2, struct iris_buffer *= buf) +{ + struct vb2_v4l2_buffer *vbuf =3D to_vb2_v4l2_buffer(vb2); + + buf->type =3D iris_v4l2_type_to_driver(vb2->type); + buf->index =3D vb2->index; + buf->fd =3D vb2->planes[0].m.fd; + buf->buffer_size =3D vb2->planes[0].length; + buf->data_offset =3D vb2->planes[0].data_offset; + buf->data_size =3D vb2->planes[0].bytesused - vb2->planes[0].data_offset; + buf->flags =3D vbuf->flags; + buf->timestamp =3D vb2->timestamp; + do_div(buf->timestamp, NSEC_PER_USEC); + buf->attr =3D 0; + + return 0; +} + +void iris_set_ts_metadata(struct iris_inst *inst, struct vb2_v4l2_buffer *= vbuf) +{ + u32 mask =3D V4L2_BUF_FLAG_TIMECODE | V4L2_BUF_FLAG_TSTAMP_SRC_MASK; + struct vb2_buffer *vb =3D &vbuf->vb2_buf; + u64 ts_us =3D vb->timestamp; + + if (inst->metadata_idx >=3D ARRAY_SIZE(inst->tss)) + inst->metadata_idx =3D 0; + + do_div(ts_us, NSEC_PER_USEC); + + inst->tss[inst->metadata_idx].flags =3D vbuf->flags & mask; + inst->tss[inst->metadata_idx].tc =3D vbuf->timecode; + inst->tss[inst->metadata_idx].ts_us =3D ts_us; + inst->tss[inst->metadata_idx].ts_ns =3D vb->timestamp; + + inst->metadata_idx++; +} + int iris_process_streamon_input(struct iris_inst *inst) { const struct iris_hfi_command_ops *hfi_ops =3D inst->core->hfi_ops; diff --git a/drivers/media/platform/qcom/iris/iris_common.h b/drivers/media= /platform/qcom/iris/iris_common.h index f385eeb53910555f17602f3951e7a6e9636a9ba2..b2a27b781c9aceb60ff43eff855= d759ea95e23d9 100644 --- a/drivers/media/platform/qcom/iris/iris_common.h +++ b/drivers/media/platform/qcom/iris/iris_common.h @@ -9,6 +9,8 @@ struct iris_inst; struct iris_buffer; =20 +int iris_vb2_buffer_to_driver(struct vb2_buffer *vb2, struct iris_buffer *= buf); +void iris_set_ts_metadata(struct iris_inst *inst, struct vb2_v4l2_buffer *= vbuf); int iris_process_streamon_input(struct iris_inst *inst); int iris_process_streamon_output(struct iris_inst *inst); int iris_session_streamoff(struct iris_inst *inst, u32 plane); diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c b/dri= vers/media/platform/qcom/iris/iris_hfi_gen1_command.c index e4c9694e29a2a6c5ab4d31184c5e000ffc417390..65648076131f5312950322216ee= 250474063b4bc 100644 --- a/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c @@ -278,23 +278,44 @@ static int iris_hfi_gen1_session_continue(struct iris= _inst *inst, u32 plane) =20 static int iris_hfi_gen1_queue_input_buffer(struct iris_inst *inst, struct= iris_buffer *buf) { - struct hfi_session_empty_buffer_compressed_pkt ip_pkt; + struct hfi_session_empty_buffer_compressed_pkt com_ip_pkt; + struct hfi_session_empty_buffer_uncompressed_pkt uncom_ip_pkt; =20 - ip_pkt.shdr.hdr.size =3D sizeof(struct hfi_session_empty_buffer_compresse= d_pkt); - ip_pkt.shdr.hdr.pkt_type =3D HFI_CMD_SESSION_EMPTY_BUFFER; - ip_pkt.shdr.session_id =3D inst->session_id; - ip_pkt.time_stamp_hi =3D upper_32_bits(buf->timestamp); - ip_pkt.time_stamp_lo =3D lower_32_bits(buf->timestamp); - ip_pkt.flags =3D buf->flags; - ip_pkt.mark_target =3D 0; - ip_pkt.mark_data =3D 0; - ip_pkt.offset =3D buf->data_offset; - ip_pkt.alloc_len =3D buf->buffer_size; - ip_pkt.filled_len =3D buf->data_size; - ip_pkt.input_tag =3D buf->index; - ip_pkt.packet_buffer =3D buf->device_addr; - - return iris_hfi_queue_cmd_write(inst->core, &ip_pkt, ip_pkt.shdr.hdr.size= ); + if (inst->domain =3D=3D DECODER) { + com_ip_pkt.shdr.hdr.size =3D sizeof(struct hfi_session_empty_buffer_comp= ressed_pkt); + com_ip_pkt.shdr.hdr.pkt_type =3D HFI_CMD_SESSION_EMPTY_BUFFER; + com_ip_pkt.shdr.session_id =3D inst->session_id; + com_ip_pkt.time_stamp_hi =3D upper_32_bits(buf->timestamp); + com_ip_pkt.time_stamp_lo =3D lower_32_bits(buf->timestamp); + com_ip_pkt.flags =3D buf->flags; + com_ip_pkt.mark_target =3D 0; + com_ip_pkt.mark_data =3D 0; + com_ip_pkt.offset =3D buf->data_offset; + com_ip_pkt.alloc_len =3D buf->buffer_size; + com_ip_pkt.filled_len =3D buf->data_size; + com_ip_pkt.input_tag =3D buf->index; + com_ip_pkt.packet_buffer =3D buf->device_addr; + return iris_hfi_queue_cmd_write(inst->core, &com_ip_pkt, + com_ip_pkt.shdr.hdr.size); + } else { + uncom_ip_pkt.shdr.hdr.size =3D + sizeof(struct hfi_session_empty_buffer_uncompressed_pkt); + uncom_ip_pkt.shdr.hdr.pkt_type =3D HFI_CMD_SESSION_EMPTY_BUFFER; + uncom_ip_pkt.shdr.session_id =3D inst->session_id; + uncom_ip_pkt.time_stamp_hi =3D upper_32_bits(buf->timestamp); + uncom_ip_pkt.time_stamp_lo =3D lower_32_bits(buf->timestamp); + uncom_ip_pkt.view_id =3D 0; + uncom_ip_pkt.flags =3D buf->flags; + uncom_ip_pkt.mark_target =3D 0; + uncom_ip_pkt.mark_data =3D 0; + uncom_ip_pkt.offset =3D buf->data_offset; + uncom_ip_pkt.alloc_len =3D buf->buffer_size; + uncom_ip_pkt.filled_len =3D buf->data_size; + uncom_ip_pkt.input_tag =3D buf->index; + uncom_ip_pkt.packet_buffer =3D buf->device_addr; + return iris_hfi_queue_cmd_write(inst->core, &uncom_ip_pkt, + uncom_ip_pkt.shdr.hdr.size); + } } =20 static int iris_hfi_gen1_queue_output_buffer(struct iris_inst *inst, struc= t iris_buffer *buf) diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen1_defines.h b/dri= vers/media/platform/qcom/iris/iris_hfi_gen1_defines.h index e96e09f08e62bd56ab639b94d2b9a469554c544c..7d447d52dbac32455cce1156e62= 4ab0f1862ff49 100644 --- a/drivers/media/platform/qcom/iris/iris_hfi_gen1_defines.h +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen1_defines.h @@ -217,6 +217,23 @@ struct hfi_session_empty_buffer_compressed_pkt { u32 data; }; =20 +struct hfi_session_empty_buffer_uncompressed_pkt { + struct hfi_session_hdr_pkt shdr; + u32 view_id; + u32 time_stamp_hi; + u32 time_stamp_lo; + u32 flags; + u32 mark_target; + u32 mark_data; + u32 alloc_len; + u32 filled_len; + u32 offset; + u32 input_tag; + u32 packet_buffer; + u32 extradata_buffer; + u32 data; +}; + struct hfi_session_fill_buffer_pkt { struct hfi_session_hdr_pkt shdr; u32 stream_id; @@ -462,6 +479,26 @@ struct hfi_msg_session_empty_buffer_done_pkt { u32 data[]; }; =20 +struct hfi_msg_session_fbd_compressed_pkt { + struct hfi_session_hdr_pkt shdr; + u32 time_stamp_hi; + u32 time_stamp_lo; + u32 error_type; + u32 flags; + u32 mark_target; + u32 mark_data; + u32 stats; + u32 offset; + u32 alloc_len; + u32 filled_len; + u32 input_tag; + u32 output_tag; + u32 picture_type; + u32 packet_buffer; + u32 extradata_buffer; + u32 data[]; +}; + struct hfi_msg_session_fbd_uncompressed_plane0_pkt { struct hfi_session_hdr_pkt shdr; u32 stream_id; diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen1_response.c b/dr= ivers/media/platform/qcom/iris/iris_hfi_gen1_response.c index 82d3e8de7bff0ac53a971b4763ae848ff8c61ff2..6b55f8d15e1097de2fb919b3069= 5ac41f7270adf 100644 --- a/drivers/media/platform/qcom/iris/iris_hfi_gen1_response.c +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen1_response.c @@ -387,24 +387,45 @@ static void iris_hfi_gen1_session_etb_done(struct iri= s_inst *inst, void *packet) =20 static void iris_hfi_gen1_session_ftb_done(struct iris_inst *inst, void *p= acket) { - struct hfi_msg_session_fbd_uncompressed_plane0_pkt *pkt =3D packet; + struct hfi_msg_session_fbd_compressed_pkt *com_pkt; + struct hfi_msg_session_fbd_uncompressed_plane0_pkt *uncom_pkt; struct v4l2_m2m_ctx *m2m_ctx =3D inst->m2m_ctx; struct v4l2_m2m_buffer *m2m_buffer, *n; struct hfi_session_flush_pkt flush_pkt; - u32 timestamp_hi =3D pkt->time_stamp_hi; - u32 timestamp_lo =3D pkt->time_stamp_lo; + u32 timestamp_hi; + u32 timestamp_lo; struct iris_core *core =3D inst->core; - u32 filled_len =3D pkt->filled_len; - u32 pic_type =3D pkt->picture_type; - u32 output_tag =3D pkt->output_tag; + u32 filled_len; + u32 pic_type; + u32 output_tag; struct iris_buffer *buf, *iter; struct iris_buffers *buffers; - u32 hfi_flags =3D pkt->flags; - u32 offset =3D pkt->offset; + u32 hfi_flags; + u32 offset; u64 timestamp_us =3D 0; bool found =3D false; u32 flags =3D 0; =20 + if (inst->domain =3D=3D DECODER) { + uncom_pkt =3D packet; + timestamp_hi =3D uncom_pkt->time_stamp_hi; + timestamp_lo =3D uncom_pkt->time_stamp_lo; + filled_len =3D uncom_pkt->filled_len; + pic_type =3D uncom_pkt->picture_type; + output_tag =3D uncom_pkt->output_tag; + hfi_flags =3D uncom_pkt->flags; + offset =3D uncom_pkt->offset; + } else { + com_pkt =3D packet; + timestamp_hi =3D com_pkt->time_stamp_hi; + timestamp_lo =3D com_pkt->time_stamp_lo; + filled_len =3D com_pkt->filled_len; + pic_type =3D com_pkt->picture_type; + output_tag =3D com_pkt->output_tag; + hfi_flags =3D com_pkt->flags; + offset =3D com_pkt->offset; + } + if ((hfi_flags & HFI_BUFFERFLAG_EOS) && !filled_len) { reinit_completion(&inst->flush_completion); =20 @@ -418,7 +439,8 @@ static void iris_hfi_gen1_session_ftb_done(struct iris_= inst *inst, void *packet) iris_inst_sub_state_change_drain_last(inst); } =20 - if (iris_split_mode_enabled(inst) && pkt->stream_id =3D=3D 0) { + if (iris_split_mode_enabled(inst) && inst->domain =3D=3D DECODER && + uncom_pkt->stream_id =3D=3D 0) { buffers =3D &inst->buffers[BUF_DPB]; if (!buffers) goto error; @@ -459,7 +481,8 @@ static void iris_hfi_gen1_session_ftb_done(struct iris_= inst *inst, void *packet) timestamp_us =3D timestamp_hi; timestamp_us =3D (timestamp_us << 32) | timestamp_lo; } else { - if (pkt->stream_id =3D=3D 1 && !inst->last_buffer_dequeued) { + if (inst->domain =3D=3D DECODER && uncom_pkt->stream_id =3D=3D 1 && + !inst->last_buffer_dequeued) { if (iris_drc_pending(inst) || iris_drain_pending(inst)) { flags |=3D V4L2_BUF_FLAG_LAST; inst->last_buffer_dequeued =3D true; @@ -551,7 +574,7 @@ static const struct iris_hfi_gen1_response_pkt_info pkt= _infos[] =3D { }, { .pkt =3D HFI_MSG_SESSION_FILL_BUFFER, - .pkt_sz =3D sizeof(struct hfi_msg_session_fbd_uncompressed_plane0_pkt), + .pkt_sz =3D sizeof(struct hfi_msg_session_fbd_compressed_pkt), }, { .pkt =3D HFI_MSG_SESSION_FLUSH, diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c b/dri= vers/media/platform/qcom/iris/iris_hfi_gen2_command.c index c71be09211bdc41fdb38551a6c416d1d252bec56..c97e4910e8528df1e18f9a68b95= 6c9fdea03d29a 100644 --- a/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c @@ -1043,13 +1043,19 @@ static int iris_hfi_gen2_session_drain(struct iris_= inst *inst, u32 plane) inst_hfi_gen2->packet->size); } =20 -static u32 iris_hfi_gen2_buf_type_from_driver(enum iris_buffer_type buffer= _type) +static u32 iris_hfi_gen2_buf_type_from_driver(u32 domain, enum iris_buffer= _type buffer_type) { switch (buffer_type) { case BUF_INPUT: - return HFI_BUFFER_BITSTREAM; + if (domain =3D=3D DECODER) + return HFI_BUFFER_BITSTREAM; + else + return HFI_BUFFER_RAW; case BUF_OUTPUT: - return HFI_BUFFER_RAW; + if (domain =3D=3D DECODER) + return HFI_BUFFER_RAW; + else + return HFI_BUFFER_BITSTREAM; case BUF_BIN: return HFI_BUFFER_BIN; case BUF_COMV: @@ -1089,16 +1095,17 @@ static int iris_set_num_comv(struct iris_inst *inst) &num_comv, sizeof(u32)); } =20 -static void iris_hfi_gen2_get_buffer(struct iris_buffer *buffer, struct ir= is_hfi_buffer *buf) +static void iris_hfi_gen2_get_buffer(u32 domain, struct iris_buffer *buffe= r, + struct iris_hfi_buffer *buf) { memset(buf, 0, sizeof(*buf)); - buf->type =3D iris_hfi_gen2_buf_type_from_driver(buffer->type); + buf->type =3D iris_hfi_gen2_buf_type_from_driver(domain, buffer->type); buf->index =3D buffer->index; buf->base_address =3D buffer->device_addr; buf->addr_offset =3D 0; buf->buffer_size =3D buffer->buffer_size; =20 - if (buffer->type =3D=3D BUF_INPUT) + if (domain =3D=3D DECODER && buffer->type =3D=3D BUF_INPUT) buf->buffer_size =3D ALIGN(buffer->buffer_size, 256); buf->data_offset =3D buffer->data_offset; buf->data_size =3D buffer->data_size; @@ -1115,7 +1122,7 @@ static int iris_hfi_gen2_session_queue_buffer(struct = iris_inst *inst, struct iri u32 port; int ret; =20 - iris_hfi_gen2_get_buffer(buffer, &hfi_buffer); + iris_hfi_gen2_get_buffer(inst->domain, buffer, &hfi_buffer); if (buffer->type =3D=3D BUF_COMV) { ret =3D iris_set_num_comv(inst); if (ret) @@ -1142,7 +1149,7 @@ static int iris_hfi_gen2_session_release_buffer(struc= t iris_inst *inst, struct i struct iris_hfi_buffer hfi_buffer; u32 port; =20 - iris_hfi_gen2_get_buffer(buffer, &hfi_buffer); + iris_hfi_gen2_get_buffer(inst->domain, buffer, &hfi_buffer); hfi_buffer.flags |=3D HFI_BUF_HOST_FLAG_RELEASE; port =3D iris_hfi_gen2_get_port_from_buf_type(inst, buffer->type); =20 diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c b/dr= ivers/media/platform/qcom/iris/iris_hfi_gen2_response.c index 6b8e637ac6d82aee8699db59ee2f04de9e715275..2f1f118eae4f6462ab1aa1d1684= 4b34e6e699f1e 100644 --- a/drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c @@ -480,12 +480,22 @@ static int iris_hfi_gen2_handle_session_buffer(struct= iris_inst *inst, if (!iris_hfi_gen2_is_valid_hfi_port(pkt->port, buffer->type)) return 0; =20 - if (buffer->type =3D=3D HFI_BUFFER_BITSTREAM) - return iris_hfi_gen2_handle_input_buffer(inst, buffer); - else if (buffer->type =3D=3D HFI_BUFFER_RAW) - return iris_hfi_gen2_handle_output_buffer(inst, buffer); - else - return iris_hfi_gen2_handle_release_internal_buffer(inst, buffer); + if (inst->domain =3D=3D DECODER) { + if (buffer->type =3D=3D HFI_BUFFER_BITSTREAM) + return iris_hfi_gen2_handle_input_buffer(inst, buffer); + else if (buffer->type =3D=3D HFI_BUFFER_RAW) + return iris_hfi_gen2_handle_output_buffer(inst, buffer); + else + return iris_hfi_gen2_handle_release_internal_buffer(inst, buffer); + } else { + if (buffer->type =3D=3D HFI_BUFFER_RAW) + return iris_hfi_gen2_handle_input_buffer(inst, buffer); + else if (buffer->type =3D=3D HFI_BUFFER_BITSTREAM) + return iris_hfi_gen2_handle_output_buffer(inst, buffer); + else + return iris_hfi_gen2_handle_release_internal_buffer(inst, buffer); + } + return 0; } =20 static int iris_hfi_gen2_handle_session_drain(struct iris_inst *inst, diff --git a/drivers/media/platform/qcom/iris/iris_vb2.c b/drivers/media/pl= atform/qcom/iris/iris_vb2.c index fbf8ebb74193284dc847c54f76f908656b3098c9..139b821f7952feb33b21a7045ae= f9e8a4782aa3c 100644 --- a/drivers/media/platform/qcom/iris/iris_vb2.c +++ b/drivers/media/platform/qcom/iris/iris_vb2.c @@ -327,7 +327,10 @@ void iris_vb2_buf_queue(struct vb2_buffer *vb2) =20 v4l2_m2m_buf_queue(m2m_ctx, vbuf); =20 - ret =3D iris_vdec_qbuf(inst, vbuf); + if (inst->domain =3D=3D DECODER) + ret =3D iris_vdec_qbuf(inst, vbuf); + else + ret =3D iris_venc_qbuf(inst, vbuf); =20 exit: if (ret) { diff --git a/drivers/media/platform/qcom/iris/iris_vdec.c b/drivers/media/p= latform/qcom/iris/iris_vdec.c index 86b5364651f587f92abcbef7b2f2a2c73f21b6b8..9ec28234fa9140434c01a6b5461= f0a83c6dac6d7 100644 --- a/drivers/media/platform/qcom/iris/iris_vdec.c +++ b/drivers/media/platform/qcom/iris/iris_vdec.c @@ -377,45 +377,6 @@ int iris_vdec_streamon_output(struct iris_inst *inst) return ret; } =20 -static int -iris_vdec_vb2_buffer_to_driver(struct vb2_buffer *vb2, struct iris_buffer = *buf) -{ - struct vb2_v4l2_buffer *vbuf =3D to_vb2_v4l2_buffer(vb2); - - buf->type =3D iris_v4l2_type_to_driver(vb2->type); - buf->index =3D vb2->index; - buf->fd =3D vb2->planes[0].m.fd; - buf->buffer_size =3D vb2->planes[0].length; - buf->data_offset =3D vb2->planes[0].data_offset; - buf->data_size =3D vb2->planes[0].bytesused - vb2->planes[0].data_offset; - buf->flags =3D vbuf->flags; - buf->timestamp =3D vb2->timestamp; - do_div(buf->timestamp, NSEC_PER_USEC); - buf->attr =3D 0; - - return 0; -} - -static void -iris_set_ts_metadata(struct iris_inst *inst, struct vb2_v4l2_buffer *vbuf) -{ - u32 mask =3D V4L2_BUF_FLAG_TIMECODE | V4L2_BUF_FLAG_TSTAMP_SRC_MASK; - struct vb2_buffer *vb =3D &vbuf->vb2_buf; - u64 ts_us =3D vb->timestamp; - - if (inst->metadata_idx >=3D ARRAY_SIZE(inst->tss)) - inst->metadata_idx =3D 0; - - do_div(ts_us, NSEC_PER_USEC); - - inst->tss[inst->metadata_idx].flags =3D vbuf->flags & mask; - inst->tss[inst->metadata_idx].tc =3D vbuf->timecode; - inst->tss[inst->metadata_idx].ts_us =3D ts_us; - inst->tss[inst->metadata_idx].ts_ns =3D vb->timestamp; - - inst->metadata_idx++; -} - int iris_vdec_qbuf(struct iris_inst *inst, struct vb2_v4l2_buffer *vbuf) { struct iris_buffer *buf =3D to_iris_buffer(vbuf); @@ -423,7 +384,7 @@ int iris_vdec_qbuf(struct iris_inst *inst, struct vb2_v= 4l2_buffer *vbuf) struct vb2_queue *q; int ret; =20 - ret =3D iris_vdec_vb2_buffer_to_driver(vb2, buf); + ret =3D iris_vb2_buffer_to_driver(vb2, buf); if (ret) return ret; =20 diff --git a/drivers/media/platform/qcom/iris/iris_venc.c b/drivers/media/p= latform/qcom/iris/iris_venc.c index bd5e8fc2d48882c4fd57607a0ce5183c65272cf9..1dc79e8fbab8d69d95ebe519d73= 6f5f2f65b2886 100644 --- a/drivers/media/platform/qcom/iris/iris_venc.c +++ b/drivers/media/platform/qcom/iris/iris_venc.c @@ -10,6 +10,7 @@ #include "iris_common.h" #include "iris_ctrls.h" #include "iris_instance.h" +#include "iris_power.h" #include "iris_venc.h" #include "iris_vpu_buffer.h" =20 @@ -493,3 +494,28 @@ int iris_venc_streamon_output(struct iris_inst *inst) =20 return ret; } + +int iris_venc_qbuf(struct iris_inst *inst, struct vb2_v4l2_buffer *vbuf) +{ + struct iris_buffer *buf =3D to_iris_buffer(vbuf); + struct vb2_buffer *vb2 =3D &vbuf->vb2_buf; + struct vb2_queue *q; + int ret; + + ret =3D iris_vb2_buffer_to_driver(vb2, buf); + if (ret) + return ret; + + if (buf->type =3D=3D BUF_INPUT) + iris_set_ts_metadata(inst, vbuf); + + q =3D v4l2_m2m_get_vq(inst->m2m_ctx, vb2->type); + if (!vb2_is_streaming(q)) { + buf->attr |=3D BUF_ATTR_DEFERRED; + return 0; + } + + iris_scale_power(inst); + + return iris_queue_buffer(inst, buf); +} diff --git a/drivers/media/platform/qcom/iris/iris_venc.h b/drivers/media/p= latform/qcom/iris/iris_venc.h index 941b5c186e4550e3eb6325d5ae3eeac4fcee4675..bbf3b635288dd6cc39719bdde19= 42918357791aa 100644 --- a/drivers/media/platform/qcom/iris/iris_venc.h +++ b/drivers/media/platform/qcom/iris/iris_venc.h @@ -20,5 +20,6 @@ int iris_venc_g_param(struct iris_inst *inst, struct v4l2= _streamparm *s_parm); int iris_venc_s_param(struct iris_inst *inst, struct v4l2_streamparm *s_pa= rm); int iris_venc_streamon_input(struct iris_inst *inst); int iris_venc_streamon_output(struct iris_inst *inst); +int iris_venc_qbuf(struct iris_inst *inst, struct vb2_v4l2_buffer *vbuf); =20 #endif diff --git a/drivers/media/platform/qcom/iris/iris_vidc.c b/drivers/media/p= latform/qcom/iris/iris_vidc.c index c2b86bb4c7d42aee8ecf2f8b9ef0015d06e82b04..ddf4443aba62a8799188c2046f8= dadfbb3e0cdbd 100644 --- a/drivers/media/platform/qcom/iris/iris_vidc.c +++ b/drivers/media/platform/qcom/iris/iris_vidc.c @@ -665,6 +665,14 @@ static const struct v4l2_ioctl_ops iris_v4l2_ioctl_ops= _enc =3D { .vidioc_g_parm =3D iris_g_parm, .vidioc_streamon =3D v4l2_m2m_ioctl_streamon, .vidioc_streamoff =3D v4l2_m2m_ioctl_streamoff, + .vidioc_reqbufs =3D v4l2_m2m_ioctl_reqbufs, + .vidioc_querybuf =3D v4l2_m2m_ioctl_querybuf, + .vidioc_create_bufs =3D v4l2_m2m_ioctl_create_bufs, + .vidioc_prepare_buf =3D v4l2_m2m_ioctl_prepare_buf, + .vidioc_expbuf =3D v4l2_m2m_ioctl_expbuf, + .vidioc_qbuf =3D v4l2_m2m_ioctl_qbuf, + .vidioc_dqbuf =3D v4l2_m2m_ioctl_dqbuf, + .vidioc_remove_bufs =3D v4l2_m2m_ioctl_remove_bufs, }; =20 void iris_init_ops(struct iris_core *core) --=20 2.34.1 From nobody Tue Oct 7 22:51:46 2025 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 B7DEC2F0046; Fri, 4 Jul 2025 07:54:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615698; cv=none; b=TdLa5G3hZIOkfvVJF3g174CSlfPay91X4aAZChWGF0nrN68zgmVr9YoKmJNyrqYpc6hhK+M8wn7i6fVOQjmtj9KXZeO1FW1ehjTfhBzRlR3VGmgAQVm6fMSRTDVS0u+0zV2NSwyOozNgfYJxo/Zy61az7jTMVcwtqVXYhzXrTYQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751615698; c=relaxed/simple; bh=lSbQKc21EFh5f7cTfTA8hlLfBNQSjFCKZNHFPnWKGKI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=f+4zhOGTMKOO11ytyYLh06Vs9vXrhrKVC59/DYSVMwdlYHnqgx9eRGNJt0YuSY7byCyvai6KuFO0MRecnMX1YV7TpbBS0NSYZP0d//oGMFfm2XBthexEPnOf6hQoWosETrrZufYMWKtTPYxcdb1GNY527zdCHXrP7jtrvT8V0/Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=EZZet3AI; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="EZZet3AI" Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5644Ldl6000729; Fri, 4 Jul 2025 07:54:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= 2D2soBNVa/YOKDhSDJ6+16GIDoySdBP61hMBMvP/J68=; b=EZZet3AI03LFiFMD RcjfRQHBvouvNT+sE4IqvaudVDmvQk8+TCwZ3keseaBv28OY95xU1+1idzzgikAH o4rSQ1XM6oHWKzuCMd2NMDvxXuNxTlQGfteEqo+m7ym5ypcuYQfd6VdwTEYEmdKe Sgc/oGWks7BUNBnQb9ZvsZjjgoEAO9991SLZU1ecn+45BKcChLmj9+Otmq7vQtqg Sx2btCx7UzQtctNwijW/8xZl4kOLONesX9vGLyYt45f9jqPOZN0RKqMDwrjfC2B7 MIbVEsrNoabwAD5RBKvfOoZRi890TUYSvS6nZTT9ImqTm1OneP5tCRaQgrkh/G6G ENOx0Q== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 47p7ut0gka-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Jul 2025 07:54:48 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA03.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 5647sm4O020922 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 4 Jul 2025 07:54:48 GMT Received: from hu-dikshita-hyd.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Fri, 4 Jul 2025 00:54:44 -0700 From: Dikshita Agarwal Date: Fri, 4 Jul 2025 13:23:25 +0530 Subject: [PATCH 25/25] media: iris: Add support for drain sequence in encoder video device Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20250704-iris-video-encoder-v1-25-b6ce24e273cf@quicinc.com> References: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> In-Reply-To: <20250704-iris-video-encoder-v1-0-b6ce24e273cf@quicinc.com> To: Vikash Garodia , Abhinav Kumar , Bryan O'Donoghue , Mauro Carvalho Chehab , Hans Verkuil , Stefan Schmidt , "Vedang Nagar" CC: , , , Dikshita Agarwal X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1751615599; l=7984; i=quic_dikshita@quicinc.com; s=20240917; h=from:subject:message-id; bh=lSbQKc21EFh5f7cTfTA8hlLfBNQSjFCKZNHFPnWKGKI=; b=fVquLTeMbn+RaEBfJIgH4MBWTP2Jp1xxXlD6goE0bJUb6vlQ+XlAEPIzpGH59OdZP+8CDucAb oJ7oVAhWgtMAcDTR+Yf/uJoDMfEd2nYonkQvAYu+SQ8I+hoXz6McM0f X-Developer-Key: i=quic_dikshita@quicinc.com; a=ed25519; pk=EEvKY6Ar1OI5SWf44FJ1Ebo1KuQEVbbf5UNPO+UHVhM= X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzA0MDA2MCBTYWx0ZWRfX5oTOFmt2Vk1D z/wXU0x6O2RLA1449AOYVbzEC3ieAK+RllbNRTAauxSbZjQVbD0ocx/SceAZCHc6wHuCKlM9N3L OSaQ+LAe3tT9qtlXcQ7V6sBXWqrQ7Ys6mzHacr+3+wqJ47k09Lq9X5LiSn2W/O91PKKxZrng9Or HJdroQQMz/ie9OXfte1YMxBIbE6H1I5xw9rbZoxDlk1vEDHjdvaEHe4aWSDcRY2c+91Scl37xsO dL++zfQEKwKeubj/STxLrdZ/JtQVm8GhVx2XNWU5Uy/hC2CBbq+AD5A2EJOxThJzYjfK/ODnl4h z3lLy00xesE/Yu0Jbbe1MzLROq/MUfaUsmoKe7ByLPIH4XSF/ZxDXYjNhFMQqgD5Y5dprDGC2pP /fZpl2sdyDEQp+2agAYIl+EE8ZBgbUxFB7X2Z0uQid2Ac0K7BOPCfJ7WA1lcakxu3OvW87DE X-Proofpoint-GUID: kc2kYpRjMdSmga9ph4BV9Dtr0pOthqk3 X-Authority-Analysis: v=2.4 cv=Ncfm13D4 c=1 sm=1 tr=0 ts=686788c8 cx=c_pps a=JYp8KDb2vCoCEuGobkYCKw==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=GEpy-HfZoHoA:10 a=IkcTkHD0fZMA:10 a=Wb1JkmetP80A:10 a=COk6AnOGAAAA:8 a=FUEJ49ZlnHEtWuKhW4YA:9 a=QEXdDO2ut3YA:10 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-ORIG-GUID: kc2kYpRjMdSmga9ph4BV9Dtr0pOthqk3 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-04_03,2025-07-02_04,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 bulkscore=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 suspectscore=0 priorityscore=1501 mlxlogscore=999 spamscore=0 malwarescore=0 adultscore=0 mlxscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505280000 definitions=main-2507040060 Add support for handling start and stop commands, including the end-of-stream (drain) sequence, in the encoder video device. This enables proper signaling to the firmware and ensures that all pending frames are processed and flushed before completing the stream. Signed-off-by: Dikshita Agarwal Tested-by: Vikash Garodia # X1E80100 --- .../platform/qcom/iris/iris_hfi_gen1_command.c | 30 ++++++++--- .../platform/qcom/iris/iris_hfi_gen1_response.c | 5 ++ drivers/media/platform/qcom/iris/iris_venc.c | 58 ++++++++++++++++++= ++++ drivers/media/platform/qcom/iris/iris_venc.h | 2 + drivers/media/platform/qcom/iris/iris_vidc.c | 35 +++++++++++++ 5 files changed, 123 insertions(+), 7 deletions(-) diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c b/dri= vers/media/platform/qcom/iris/iris_hfi_gen1_command.c index 65648076131f5312950322216ee250474063b4bc..fff5631423330d22ead4891654f= cc38d8b55e0f5 100644 --- a/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c @@ -455,15 +455,31 @@ static int iris_hfi_gen1_session_unset_buffers(struct= iris_inst *inst, struct ir =20 static int iris_hfi_gen1_session_drain(struct iris_inst *inst, u32 plane) { - struct hfi_session_empty_buffer_compressed_pkt ip_pkt =3D {0}; + if (inst->domain =3D=3D DECODER) { + struct hfi_session_empty_buffer_compressed_pkt ip_pkt =3D {0}; + + ip_pkt.shdr.hdr.size =3D sizeof(struct hfi_session_empty_buffer_compress= ed_pkt); + ip_pkt.shdr.hdr.pkt_type =3D HFI_CMD_SESSION_EMPTY_BUFFER; + ip_pkt.shdr.session_id =3D inst->session_id; + ip_pkt.flags =3D HFI_BUFFERFLAG_EOS; + ip_pkt.packet_buffer =3D 0xdeadb000; + + return iris_hfi_queue_cmd_write(inst->core, &ip_pkt, ip_pkt.shdr.hdr.siz= e); + } =20 - ip_pkt.shdr.hdr.size =3D sizeof(struct hfi_session_empty_buffer_compresse= d_pkt); - ip_pkt.shdr.hdr.pkt_type =3D HFI_CMD_SESSION_EMPTY_BUFFER; - ip_pkt.shdr.session_id =3D inst->session_id; - ip_pkt.flags =3D HFI_BUFFERFLAG_EOS; - ip_pkt.packet_buffer =3D 0xdeadb000; + if (inst->domain =3D=3D ENCODER) { + struct hfi_session_empty_buffer_uncompressed_pkt ip_pkt =3D {0}; + + ip_pkt.shdr.hdr.size =3D sizeof(struct hfi_session_empty_buffer_uncompre= ssed_pkt); + ip_pkt.shdr.hdr.pkt_type =3D HFI_CMD_SESSION_EMPTY_BUFFER; + ip_pkt.shdr.session_id =3D inst->session_id; + ip_pkt.flags =3D HFI_BUFFERFLAG_EOS; + ip_pkt.packet_buffer =3D 0xdeadb000; + + return iris_hfi_queue_cmd_write(inst->core, &ip_pkt, ip_pkt.shdr.hdr.siz= e); + } =20 - return iris_hfi_queue_cmd_write(inst->core, &ip_pkt, ip_pkt.shdr.hdr.size= ); + return -EINVAL; } =20 static int diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen1_response.c b/dr= ivers/media/platform/qcom/iris/iris_hfi_gen1_response.c index 6b55f8d15e1097de2fb919b30695ac41f7270adf..c4750d60cb93dab9be8a02edf47= 305d6a046a6ac 100644 --- a/drivers/media/platform/qcom/iris/iris_hfi_gen1_response.c +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen1_response.c @@ -487,6 +487,11 @@ static void iris_hfi_gen1_session_ftb_done(struct iris= _inst *inst, void *packet) flags |=3D V4L2_BUF_FLAG_LAST; inst->last_buffer_dequeued =3D true; } + } else if (inst->domain =3D=3D ENCODER) { + if (!inst->last_buffer_dequeued && iris_drain_pending(inst)) { + flags |=3D V4L2_BUF_FLAG_LAST; + inst->last_buffer_dequeued =3D true; + } } } buf->timestamp =3D timestamp_us; diff --git a/drivers/media/platform/qcom/iris/iris_venc.c b/drivers/media/p= latform/qcom/iris/iris_venc.c index 1dc79e8fbab8d69d95ebe519d736f5f2f65b2886..719baa3f82f01fdc10f0eb6c246= 0186b141ae1e9 100644 --- a/drivers/media/platform/qcom/iris/iris_venc.c +++ b/drivers/media/platform/qcom/iris/iris_venc.c @@ -519,3 +519,61 @@ int iris_venc_qbuf(struct iris_inst *inst, struct vb2_= v4l2_buffer *vbuf) =20 return iris_queue_buffer(inst, buf); } + +int iris_venc_start_cmd(struct iris_inst *inst) +{ + const struct iris_hfi_command_ops *hfi_ops =3D inst->core->hfi_ops; + enum iris_inst_sub_state clear_sub_state =3D 0; + struct vb2_queue *dst_vq; + int ret; + + dst_vq =3D v4l2_m2m_get_dst_vq(inst->m2m_ctx); + + if (inst->sub_state & IRIS_INST_SUB_DRAIN && + inst->sub_state & IRIS_INST_SUB_DRAIN_LAST) { + vb2_clear_last_buffer_dequeued(dst_vq); + clear_sub_state =3D IRIS_INST_SUB_DRAIN | IRIS_INST_SUB_DRAIN_LAST; + if (inst->sub_state & IRIS_INST_SUB_INPUT_PAUSE) { + if (hfi_ops->session_resume_drain) { + ret =3D hfi_ops->session_resume_drain(inst, + V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); + if (ret) + return ret; + } + clear_sub_state |=3D IRIS_INST_SUB_INPUT_PAUSE; + } + if (inst->sub_state & IRIS_INST_SUB_OUTPUT_PAUSE) { + if (hfi_ops->session_resume_drain) { + ret =3D hfi_ops->session_resume_drain(inst, + V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); + if (ret) + return ret; + } + clear_sub_state |=3D IRIS_INST_SUB_OUTPUT_PAUSE; + } + } else { + dev_err(inst->core->dev, "start called before receiving last_flag\n"); + iris_inst_change_state(inst, IRIS_INST_ERROR); + return -EBUSY; + } + + inst->last_buffer_dequeued =3D false; + + return iris_inst_change_sub_state(inst, clear_sub_state, 0); +} + +int iris_venc_stop_cmd(struct iris_inst *inst) +{ + const struct iris_hfi_command_ops *hfi_ops =3D inst->core->hfi_ops; + int ret; + + ret =3D hfi_ops->session_drain(inst, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); + if (ret) + return ret; + + ret =3D iris_inst_change_sub_state(inst, 0, IRIS_INST_SUB_DRAIN); + + iris_scale_power(inst); + + return ret; +} diff --git a/drivers/media/platform/qcom/iris/iris_venc.h b/drivers/media/p= latform/qcom/iris/iris_venc.h index bbf3b635288dd6cc39719bdde1942918357791aa..c4db7433da537578e05d566d53d= 89a22e1901678 100644 --- a/drivers/media/platform/qcom/iris/iris_venc.h +++ b/drivers/media/platform/qcom/iris/iris_venc.h @@ -21,5 +21,7 @@ int iris_venc_s_param(struct iris_inst *inst, struct v4l2= _streamparm *s_parm); int iris_venc_streamon_input(struct iris_inst *inst); int iris_venc_streamon_output(struct iris_inst *inst); int iris_venc_qbuf(struct iris_inst *inst, struct vb2_v4l2_buffer *vbuf); +int iris_venc_start_cmd(struct iris_inst *inst); +int iris_venc_stop_cmd(struct iris_inst *inst); =20 #endif diff --git a/drivers/media/platform/qcom/iris/iris_vidc.c b/drivers/media/p= latform/qcom/iris/iris_vidc.c index ddf4443aba62a8799188c2046f8dadfbb3e0cdbd..01338c7f3125d982360ed8168f9= 5ab572c9e5897 100644 --- a/drivers/media/platform/qcom/iris/iris_vidc.c +++ b/drivers/media/platform/qcom/iris/iris_vidc.c @@ -598,6 +598,39 @@ static int iris_dec_cmd(struct file *filp, void *fh, return ret; } =20 +static int iris_enc_cmd(struct file *filp, void *fh, + struct v4l2_encoder_cmd *enc) +{ + struct iris_inst *inst =3D iris_get_inst(filp, NULL); + int ret =3D 0; + + mutex_lock(&inst->lock); + + ret =3D v4l2_m2m_ioctl_encoder_cmd(filp, fh, enc); + if (ret) + goto unlock; + + if (inst->state =3D=3D IRIS_INST_DEINIT) + goto unlock; + + if (!iris_allow_cmd(inst, enc->cmd)) { + ret =3D -EBUSY; + goto unlock; + } + + if (enc->cmd =3D=3D V4L2_ENC_CMD_START) + ret =3D iris_venc_start_cmd(inst); + else if (enc->cmd =3D=3D V4L2_ENC_CMD_STOP) + ret =3D iris_venc_stop_cmd(inst); + else + ret =3D -EINVAL; + +unlock: + mutex_unlock(&inst->lock); + + return ret; +} + static struct v4l2_file_operations iris_v4l2_file_ops =3D { .owner =3D THIS_MODULE, .open =3D iris_open, @@ -673,6 +706,8 @@ static const struct v4l2_ioctl_ops iris_v4l2_ioctl_ops_= enc =3D { .vidioc_qbuf =3D v4l2_m2m_ioctl_qbuf, .vidioc_dqbuf =3D v4l2_m2m_ioctl_dqbuf, .vidioc_remove_bufs =3D v4l2_m2m_ioctl_remove_bufs, + .vidioc_try_encoder_cmd =3D v4l2_m2m_ioctl_try_encoder_cmd, + .vidioc_encoder_cmd =3D iris_enc_cmd, }; =20 void iris_init_ops(struct iris_core *core) --=20 2.34.1