From patchwork Mon Jun 12 16:27:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 103665 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp10604qgd; Mon, 12 Jun 2017 09:34:59 -0700 (PDT) X-Received: by 10.99.39.194 with SMTP id n185mr50235411pgn.94.1497285299614; Mon, 12 Jun 2017 09:34:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497285299; cv=none; d=google.com; s=arc-20160816; b=OPbKdbqbc8LLF03NdoOzD/a2YrKDfaovSg54BY72GS37iCf4WfLhkJzUrUO4IqxIve ePOHjsTh/Jo40PkmjrYHudADxH4nvXNfpQA8Df77wjda1L1KuiMf/wpLsdjhc5xubxSo LC0A4SZSsVhOd5Ez/XSFSco8OywdPEfveoIGzBkqnaLPb/kPwBDZ6ZUvqY8cCpc1fS2v nFoR0mRvnAiQTbWbFiJxeK+8ZZHjxd1wk3mPkl97DdOTxGXXSLs5fyauLpS0Aws7fYIc viG/r+r8HNKNDRORZNwwqZL+RXIEfByGQCRBbYzNnhj/MSzzbltIJNRiDqXfaaKE96rp 3Jbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=wi6u2lS/T7BnjKSdSYU5I7pdkgitEbedE7MLsk5FnHg=; b=xDVIAYK0wnc5KOEppBlCvUEFpA0inx0m1BXqbd6mIIa1U5efZMLoWAyfyBZ7425y3V RfjWcq6BKLohUTrTaIY5M8q2uQc9Bd9mKgAUYGiKddD7+LjNTffyD7no8dyLz+TVze0I vCRyL27Vcu92DG7SuyuYzWMhojNpw2bELoIeYK1XxPyf7KQVBZ/SDqk5/NXGeqW0w4Nf eZH+cqHn1GA2/bQl0/bN3AnTJuI1YBCmMzyYWOoJxJIt1lOVEzDHkkLgm/AEmfOk2Jms 4zKloljUtm5O/ol1cGtrqFwAh1D6miyMNAvgP6YSicXPRzaL/gO/3dQ+XReeSos/w2A5 501Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z6si7179792pfb.28.2017.06.12.09.34.59; Mon, 12 Jun 2017 09:34:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754585AbdFLQel (ORCPT + 25 others); Mon, 12 Jun 2017 12:34:41 -0400 Received: from mail-wr0-f171.google.com ([209.85.128.171]:32999 "EHLO mail-wr0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753857AbdFLQ3c (ORCPT ); Mon, 12 Jun 2017 12:29:32 -0400 Received: by mail-wr0-f171.google.com with SMTP id v104so101954808wrb.0 for ; Mon, 12 Jun 2017 09:29:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wi6u2lS/T7BnjKSdSYU5I7pdkgitEbedE7MLsk5FnHg=; b=CEtcwLR8zy2JxRjTcehfYo7v+KtG2cirOjUb2py3L0WHSYlmfX8XswY/XCDrZpweIM etUQ17tuWro14r5cngPvPayUPuli7UTEcuekRQKjsoPvRT/8gvGl/YwM2IrPEVTFdDtO L6xwdbZ9aK7WH89ott6rSlNGsLRG/dABJC0zI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wi6u2lS/T7BnjKSdSYU5I7pdkgitEbedE7MLsk5FnHg=; b=CxuOKq/YH8qFoOc0XpCIHAvleSX9+M3tcfJgTiTlOBHpaa2CymPK7gqp0ioRu2nzes fT4i7EU9VmhNugGnrD7zeQBjWAExsq/6HVrwodYCJJWE4XHVofMrvjg1UtwwbwLKHVFQ Cd1Iv21/nxZanDEBwi3CDuPMI7Po1e7mInNDxHnAMeFy+rCYKW7Kb+5IH6K6cjeYmCnq 8BINB6/xQ2Pf9jiG6RyO9RUUtKai6PvODSmsA4MSg5nSNr6TGWvyHGn0e6NyhQHznXDZ iSbBleiVAHf0Tr50YeXyIZ5dh+NaoxlawR1AZ6sJ/PhRe6fQgpbV1V9dtYjEV0ngOkYZ SRPg== X-Gm-Message-State: AKS2vOzeyH5IyT2davm+OPvAfy5EsJf55SAUxxWZ3QtOmNF30KZhF0xx uBL0xwxUO0cQOYvz X-Received: by 10.28.26.18 with SMTP id a18mr8239947wma.34.1497284968327; Mon, 12 Jun 2017 09:29:28 -0700 (PDT) Received: from mms-0440.qualcomm.mm-sol.com ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id 49sm14493531wrz.8.2017.06.12.09.29.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 12 Jun 2017 09:29:27 -0700 (PDT) From: Stanimir Varbanov To: Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Stanimir Varbanov Subject: [PATCH v10 03/18] MAINTAINERS: Add Qualcomm Venus video accelerator driver Date: Mon, 12 Jun 2017 19:27:40 +0300 Message-Id: <1497284875-19999-4-git-send-email-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497284875-19999-1-git-send-email-stanimir.varbanov@linaro.org> References: <1497284875-19999-1-git-send-email-stanimir.varbanov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add an entry for Venus video encoder/decoder accelerator driver. Signed-off-by: Stanimir Varbanov --- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+) -- 2.7.4 diff --git a/MAINTAINERS b/MAINTAINERS index 053c3bdd1fe5..2cf03bb969b5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -10584,6 +10584,14 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/rkuo/linux-hexagon-kernel.g S: Supported F: arch/hexagon/ +QUALCOMM VENUS VIDEO ACCELERATOR DRIVER +M: Stanimir Varbanov +L: linux-media@vger.kernel.org +L: linux-arm-msm@vger.kernel.org +T: git git://linuxtv.org/media_tree.git +S: Maintained +F: drivers/media/platform/qcom/venus/ + QUALCOMM WCN36XX WIRELESS DRIVER M: Eugene Krasnikov L: wcn36xx@lists.infradead.org From patchwork Mon Jun 12 16:27:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 103651 Delivered-To: patch@linaro.org Received: by 10.182.29.35 with SMTP id g3csp76743obh; Mon, 12 Jun 2017 09:30:17 -0700 (PDT) X-Received: by 10.84.230.129 with SMTP id e1mr55111589plk.88.1497285017890; Mon, 12 Jun 2017 09:30:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497285017; cv=none; d=google.com; s=arc-20160816; b=KgpOzqydaK9h5+1NkTFgOAbNS1UUm+fMhGiQr/zMAtjQEV0FPod2/mXXowZOjPjSsc 6PVcJlGEl1sSkVXbQKZmRu7pSx3kP6Ob0ruvbDA6yFMfKuhMB+GX00FPOdmL9r2I0S4T liCAG+EOZt/ZqONgW6mtXfbezlu6HirUZHie532+zsnNRRc63uEN1EJGxJoeH57GXZzW gwPfOVcx0u5nXRIcOqBNG2ds9hcIaFW25zG4uiSFK/CYHZ2xM8R6qM59tcpFHE9pLdX2 pQahphphDWQKLF4EUbwsE0/+gmVhFlTietjpe6tuMPLXpGxP5h6tcGKlRsBBjq4eExZT jf/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=sXZLHz/FnColZ6R5vvBy/brIm5hcndTnDQsD9B3lIfI=; b=maIkKVJxVUEH2hAtTLHaS8QBnDr19IAeDJzZ12lJdZJC2Gzueh4xmT6P7BPO5MTqnY LXB7IFj8ejeV0QJWlJy00ZmlLP89qjNbdB5jKVA4hkyO5YwH7roOxv4kg5Du/v3KkAdT ON1TK2yARFbgNN/I/P5tjS4KEKbbBc6pZq5mMm8NQ23/Dd1iJA2rwZiShI5EngUF4bId ZKgK8BAd14BdJxQdXxTMBxPNElN7vTIFCY6w+jjo2ixiwJ/LJDD1l+amr93f3ZdpXO1W WHk55DIHYUUEVTiAGQDx+0ks5hm8gBncxTARmMHF63J6r2CJyayNdL0raFGdPPLnQ9lx 34Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c32si5132695plj.195.2017.06.12.09.30.17; Mon, 12 Jun 2017 09:30:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754848AbdFLQ3s (ORCPT + 25 others); Mon, 12 Jun 2017 12:29:48 -0400 Received: from mail-wr0-f178.google.com ([209.85.128.178]:33070 "EHLO mail-wr0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932076AbdFLQ3o (ORCPT ); Mon, 12 Jun 2017 12:29:44 -0400 Received: by mail-wr0-f178.google.com with SMTP id v104so101958241wrb.0 for ; Mon, 12 Jun 2017 09:29:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sXZLHz/FnColZ6R5vvBy/brIm5hcndTnDQsD9B3lIfI=; b=kQ4kFbbHW7+vVJ07eZ89BiQR/iSEl3iKx4H5f+mJgVEsDuE1R9gn4If3PQUcesFwZ2 E5RjzunnMYfV3QMZwI0YsNKdvEZUqrive+qj8Hbo5BqHKSrnsk991G6xEHkwTzkeGHAo AJAqHm7F5y8P4By/YzYX6SwLXXpkfx0HmKKK0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=sXZLHz/FnColZ6R5vvBy/brIm5hcndTnDQsD9B3lIfI=; b=U4pQyS/1Cwwlj1R0B+tsYo8D8m2KfOWGz47CMzRp2F50psEvLXUs9w6OGKz1HRLNVN vSKNgB8uvrIDuEG0wAdM2mBqCbJKRggU/fY3U10cjLW58qhZYI6SHv35IodwMzSU9EwM ZSUZLkH4P4hGYQNe4yQoih3WCwlZD4ug5SzYmOQKbXeFqU2gqqM8RKUfQdWwm+13Ar5U BPSjVQrUjRbmJMhK9P/33ftLdNcgOq913DLwqGVTVHYcY3MBY+koAoLCQ6a48cJseJi2 pgiAwiqjVadUp8FLCDFalDIzGrDo4W7pjHItdaBJDnLi3sh+s8qyksQ2eJFuwMKphmo3 eJ2Q== X-Gm-Message-State: AKS2vOyKXrzVI59axkIIWFqrSE7iuUKQWl9imP/0XdSkEFJ4yKEDyxvH zSpTrB+NTpoYc9Gr X-Received: by 10.28.138.16 with SMTP id m16mr7612983wmd.99.1497284974525; Mon, 12 Jun 2017 09:29:34 -0700 (PDT) Received: from mms-0440.qualcomm.mm-sol.com ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id 49sm14493531wrz.8.2017.06.12.09.29.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 12 Jun 2017 09:29:33 -0700 (PDT) From: Stanimir Varbanov To: Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Stanimir Varbanov Subject: [PATCH v10 05/18] media: venus: vdec: add video decoder files Date: Mon, 12 Jun 2017 19:27:42 +0300 Message-Id: <1497284875-19999-6-git-send-email-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497284875-19999-1-git-send-email-stanimir.varbanov@linaro.org> References: <1497284875-19999-1-git-send-email-stanimir.varbanov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This consists of video decoder implementation plus decoder controls. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/vdec.c | 1154 ++++++++++++++++++++++++ drivers/media/platform/qcom/venus/vdec.h | 23 + drivers/media/platform/qcom/venus/vdec_ctrls.c | 150 +++ 3 files changed, 1327 insertions(+) create mode 100644 drivers/media/platform/qcom/venus/vdec.c create mode 100644 drivers/media/platform/qcom/venus/vdec.h create mode 100644 drivers/media/platform/qcom/venus/vdec_ctrls.c -- 2.7.4 diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c new file mode 100644 index 000000000000..96e7e7e71e5f --- /dev/null +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -0,0 +1,1154 @@ +/* + * Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. + * Copyright (C) 2017 Linaro Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "hfi_venus_io.h" +#include "core.h" +#include "helpers.h" +#include "vdec.h" + +static u32 get_framesize_uncompressed(unsigned int plane, u32 width, u32 height) +{ + u32 y_stride, uv_stride, y_plane; + u32 y_sclines, uv_sclines, uv_plane; + u32 size; + + y_stride = ALIGN(width, 128); + uv_stride = ALIGN(width, 128); + y_sclines = ALIGN(height, 32); + uv_sclines = ALIGN(((height + 1) >> 1), 16); + + y_plane = y_stride * y_sclines; + uv_plane = uv_stride * uv_sclines + SZ_4K; + size = y_plane + uv_plane + SZ_8K; + + return ALIGN(size, SZ_4K); +} + +static u32 get_framesize_compressed(unsigned int width, unsigned int height) +{ + return ((width * height * 3 / 2) / 2) + 128; +} + +/* + * Three resons to keep MPLANE formats (despite that the number of planes + * currently is one): + * - the MPLANE formats allow only one plane to be used + * - the downstream driver use MPLANE formats too + * - future firmware versions could add support for >1 planes + */ +static const struct venus_format vdec_formats[] = { + { + .pixfmt = V4L2_PIX_FMT_NV12, + .num_planes = 1, + .type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, + }, { + .pixfmt = V4L2_PIX_FMT_MPEG4, + .num_planes = 1, + .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, + }, { + .pixfmt = V4L2_PIX_FMT_MPEG2, + .num_planes = 1, + .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, + }, { + .pixfmt = V4L2_PIX_FMT_H263, + .num_planes = 1, + .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, + }, { + .pixfmt = V4L2_PIX_FMT_VC1_ANNEX_G, + .num_planes = 1, + .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, + }, { + .pixfmt = V4L2_PIX_FMT_VC1_ANNEX_L, + .num_planes = 1, + .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, + }, { + .pixfmt = V4L2_PIX_FMT_H264, + .num_planes = 1, + .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, + }, { + .pixfmt = V4L2_PIX_FMT_VP8, + .num_planes = 1, + .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, + }, { + .pixfmt = V4L2_PIX_FMT_VP9, + .num_planes = 1, + .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, + }, { + .pixfmt = V4L2_PIX_FMT_XVID, + .num_planes = 1, + .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, + }, +}; + +static const struct venus_format *find_format(u32 pixfmt, u32 type) +{ + const struct venus_format *fmt = vdec_formats; + unsigned int size = ARRAY_SIZE(vdec_formats); + unsigned int i; + + for (i = 0; i < size; i++) { + if (fmt[i].pixfmt == pixfmt) + break; + } + + if (i == size || fmt[i].type != type) + return NULL; + + return &fmt[i]; +} + +static const struct venus_format * +find_format_by_index(unsigned int index, u32 type) +{ + const struct venus_format *fmt = vdec_formats; + unsigned int size = ARRAY_SIZE(vdec_formats); + unsigned int i, k = 0; + + if (index > size) + return NULL; + + for (i = 0; i < size; i++) { + if (fmt[i].type != type) + continue; + if (k == index) + break; + k++; + } + + if (i == size) + return NULL; + + return &fmt[i]; +} + +static const struct venus_format * +vdec_try_fmt_common(struct venus_inst *inst, struct v4l2_format *f) +{ + struct v4l2_pix_format_mplane *pixmp = &f->fmt.pix_mp; + struct v4l2_plane_pix_format *pfmt = pixmp->plane_fmt; + const struct venus_format *fmt; + unsigned int p; + + memset(pfmt[0].reserved, 0, sizeof(pfmt[0].reserved)); + memset(pixmp->reserved, 0, sizeof(pixmp->reserved)); + + fmt = find_format(pixmp->pixelformat, f->type); + if (!fmt) { + if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) + pixmp->pixelformat = V4L2_PIX_FMT_NV12; + else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) + pixmp->pixelformat = V4L2_PIX_FMT_H264; + else + return NULL; + fmt = find_format(pixmp->pixelformat, f->type); + pixmp->width = 1280; + pixmp->height = 720; + } + + pixmp->width = clamp(pixmp->width, inst->cap_width.min, + inst->cap_width.max); + pixmp->height = clamp(pixmp->height, inst->cap_height.min, + inst->cap_height.max); + + if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) + pixmp->height = ALIGN(pixmp->height, 32); + + if (pixmp->field == V4L2_FIELD_ANY) + pixmp->field = V4L2_FIELD_NONE; + pixmp->num_planes = fmt->num_planes; + pixmp->flags = 0; + + if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { + for (p = 0; p < pixmp->num_planes; p++) { + pfmt[p].sizeimage = + get_framesize_uncompressed(p, pixmp->width, + pixmp->height); + pfmt[p].bytesperline = ALIGN(pixmp->width, 128); + } + } else { + pfmt[0].sizeimage = get_framesize_compressed(pixmp->width, + pixmp->height); + pfmt[0].bytesperline = 0; + } + + return fmt; +} + +static int vdec_try_fmt(struct file *file, void *fh, struct v4l2_format *f) +{ + struct venus_inst *inst = to_inst(file); + + vdec_try_fmt_common(inst, f); + + return 0; +} + +static int vdec_g_fmt(struct file *file, void *fh, struct v4l2_format *f) +{ + struct venus_inst *inst = to_inst(file); + const struct venus_format *fmt = NULL; + struct v4l2_pix_format_mplane *pixmp = &f->fmt.pix_mp; + + if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) + fmt = inst->fmt_cap; + else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) + fmt = inst->fmt_out; + + if (inst->reconfig) { + struct v4l2_format format = {}; + + inst->out_width = inst->reconfig_width; + inst->out_height = inst->reconfig_height; + inst->reconfig = false; + + format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; + format.fmt.pix_mp.pixelformat = inst->fmt_cap->pixfmt; + format.fmt.pix_mp.width = inst->out_width; + format.fmt.pix_mp.height = inst->out_height; + + vdec_try_fmt_common(inst, &format); + + inst->width = format.fmt.pix_mp.width; + inst->height = format.fmt.pix_mp.height; + } + + pixmp->pixelformat = fmt->pixfmt; + + if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { + pixmp->width = inst->width; + pixmp->height = inst->height; + pixmp->colorspace = inst->colorspace; + pixmp->ycbcr_enc = inst->ycbcr_enc; + pixmp->quantization = inst->quantization; + pixmp->xfer_func = inst->xfer_func; + } else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { + pixmp->width = inst->out_width; + pixmp->height = inst->out_height; + } + + vdec_try_fmt_common(inst, f); + + return 0; +} + +static int vdec_s_fmt(struct file *file, void *fh, struct v4l2_format *f) +{ + struct venus_inst *inst = to_inst(file); + struct v4l2_pix_format_mplane *pixmp = &f->fmt.pix_mp; + struct v4l2_pix_format_mplane orig_pixmp; + const struct venus_format *fmt; + struct v4l2_format format; + u32 pixfmt_out = 0, pixfmt_cap = 0; + + orig_pixmp = *pixmp; + + fmt = vdec_try_fmt_common(inst, f); + + if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { + pixfmt_out = pixmp->pixelformat; + pixfmt_cap = inst->fmt_cap->pixfmt; + } else if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { + pixfmt_cap = pixmp->pixelformat; + pixfmt_out = inst->fmt_out->pixfmt; + } + + memset(&format, 0, sizeof(format)); + + format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; + format.fmt.pix_mp.pixelformat = pixfmt_out; + format.fmt.pix_mp.width = orig_pixmp.width; + format.fmt.pix_mp.height = orig_pixmp.height; + vdec_try_fmt_common(inst, &format); + + if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { + inst->out_width = format.fmt.pix_mp.width; + inst->out_height = format.fmt.pix_mp.height; + inst->colorspace = pixmp->colorspace; + inst->ycbcr_enc = pixmp->ycbcr_enc; + inst->quantization = pixmp->quantization; + inst->xfer_func = pixmp->xfer_func; + } + + memset(&format, 0, sizeof(format)); + + format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; + format.fmt.pix_mp.pixelformat = pixfmt_cap; + format.fmt.pix_mp.width = orig_pixmp.width; + format.fmt.pix_mp.height = orig_pixmp.height; + vdec_try_fmt_common(inst, &format); + + inst->width = format.fmt.pix_mp.width; + inst->height = format.fmt.pix_mp.height; + + if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) + inst->fmt_out = fmt; + else if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) + inst->fmt_cap = fmt; + + return 0; +} + +static int +vdec_g_selection(struct file *file, void *fh, struct v4l2_selection *s) +{ + struct venus_inst *inst = to_inst(file); + + if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE && + s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) + return -EINVAL; + + switch (s->target) { + case V4L2_SEL_TGT_CROP_BOUNDS: + case V4L2_SEL_TGT_CROP_DEFAULT: + case V4L2_SEL_TGT_CROP: + if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) + return -EINVAL; + s->r.width = inst->out_width; + s->r.height = inst->out_height; + break; + case V4L2_SEL_TGT_COMPOSE_BOUNDS: + case V4L2_SEL_TGT_COMPOSE_PADDED: + if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) + return -EINVAL; + s->r.width = inst->width; + s->r.height = inst->height; + break; + case V4L2_SEL_TGT_COMPOSE_DEFAULT: + case V4L2_SEL_TGT_COMPOSE: + if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) + return -EINVAL; + s->r.width = inst->out_width; + s->r.height = inst->out_height; + break; + default: + return -EINVAL; + } + + s->r.top = 0; + s->r.left = 0; + + return 0; +} + +static int +vdec_querycap(struct file *file, void *fh, struct v4l2_capability *cap) +{ + strlcpy(cap->driver, "qcom-venus", sizeof(cap->driver)); + strlcpy(cap->card, "Qualcomm Venus video decoder", sizeof(cap->card)); + strlcpy(cap->bus_info, "platform:qcom-venus", sizeof(cap->bus_info)); + + return 0; +} + +static int vdec_enum_fmt(struct file *file, void *fh, struct v4l2_fmtdesc *f) +{ + const struct venus_format *fmt; + + memset(f->reserved, 0, sizeof(f->reserved)); + + fmt = find_format_by_index(f->index, f->type); + if (!fmt) + return -EINVAL; + + f->pixelformat = fmt->pixfmt; + + return 0; +} + +static int vdec_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a) +{ + struct venus_inst *inst = to_inst(file); + struct v4l2_captureparm *cap = &a->parm.capture; + struct v4l2_fract *timeperframe = &cap->timeperframe; + u64 us_per_frame, fps; + + if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE && + a->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) + return -EINVAL; + + memset(cap->reserved, 0, sizeof(cap->reserved)); + if (!timeperframe->denominator) + timeperframe->denominator = inst->timeperframe.denominator; + if (!timeperframe->numerator) + timeperframe->numerator = inst->timeperframe.numerator; + cap->readbuffers = 0; + cap->extendedmode = 0; + cap->capability = V4L2_CAP_TIMEPERFRAME; + us_per_frame = timeperframe->numerator * (u64)USEC_PER_SEC; + do_div(us_per_frame, timeperframe->denominator); + + if (!us_per_frame) + return -EINVAL; + + fps = (u64)USEC_PER_SEC; + do_div(fps, us_per_frame); + + inst->fps = fps; + inst->timeperframe = *timeperframe; + + return 0; +} + +static int vdec_enum_framesizes(struct file *file, void *fh, + struct v4l2_frmsizeenum *fsize) +{ + struct venus_inst *inst = to_inst(file); + const struct venus_format *fmt; + + fmt = find_format(fsize->pixel_format, + V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); + if (!fmt) { + fmt = find_format(fsize->pixel_format, + V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); + if (!fmt) + return -EINVAL; + } + + if (fsize->index) + return -EINVAL; + + fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE; + + fsize->stepwise.min_width = inst->cap_width.min; + fsize->stepwise.max_width = inst->cap_width.max; + fsize->stepwise.step_width = inst->cap_width.step_size; + fsize->stepwise.min_height = inst->cap_height.min; + fsize->stepwise.max_height = inst->cap_height.max; + fsize->stepwise.step_height = inst->cap_height.step_size; + + return 0; +} + +static int vdec_subscribe_event(struct v4l2_fh *fh, + const struct v4l2_event_subscription *sub) +{ + switch (sub->type) { + case V4L2_EVENT_EOS: + return v4l2_event_subscribe(fh, sub, 2, NULL); + case V4L2_EVENT_SOURCE_CHANGE: + return v4l2_src_change_event_subscribe(fh, sub); + case V4L2_EVENT_CTRL: + return v4l2_ctrl_subscribe_event(fh, sub); + default: + return -EINVAL; + } +} + +static int +vdec_try_decoder_cmd(struct file *file, void *fh, struct v4l2_decoder_cmd *cmd) +{ + if (cmd->cmd != V4L2_DEC_CMD_STOP) + return -EINVAL; + + return 0; +} + +static int +vdec_decoder_cmd(struct file *file, void *fh, struct v4l2_decoder_cmd *cmd) +{ + struct venus_inst *inst = to_inst(file); + int ret; + + ret = vdec_try_decoder_cmd(file, fh, cmd); + if (ret) + return ret; + + mutex_lock(&inst->lock); + inst->cmd_stop = true; + mutex_unlock(&inst->lock); + + hfi_session_flush(inst); + + return 0; +} + +static const struct v4l2_ioctl_ops vdec_ioctl_ops = { + .vidioc_querycap = vdec_querycap, + .vidioc_enum_fmt_vid_cap_mplane = vdec_enum_fmt, + .vidioc_enum_fmt_vid_out_mplane = vdec_enum_fmt, + .vidioc_s_fmt_vid_cap_mplane = vdec_s_fmt, + .vidioc_s_fmt_vid_out_mplane = vdec_s_fmt, + .vidioc_g_fmt_vid_cap_mplane = vdec_g_fmt, + .vidioc_g_fmt_vid_out_mplane = vdec_g_fmt, + .vidioc_try_fmt_vid_cap_mplane = vdec_try_fmt, + .vidioc_try_fmt_vid_out_mplane = vdec_try_fmt, + .vidioc_g_selection = vdec_g_selection, + .vidioc_reqbufs = v4l2_m2m_ioctl_reqbufs, + .vidioc_querybuf = v4l2_m2m_ioctl_querybuf, + .vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs, + .vidioc_prepare_buf = v4l2_m2m_ioctl_prepare_buf, + .vidioc_qbuf = v4l2_m2m_ioctl_qbuf, + .vidioc_expbuf = v4l2_m2m_ioctl_expbuf, + .vidioc_dqbuf = v4l2_m2m_ioctl_dqbuf, + .vidioc_streamon = v4l2_m2m_ioctl_streamon, + .vidioc_streamoff = v4l2_m2m_ioctl_streamoff, + .vidioc_s_parm = vdec_s_parm, + .vidioc_enum_framesizes = vdec_enum_framesizes, + .vidioc_subscribe_event = vdec_subscribe_event, + .vidioc_unsubscribe_event = v4l2_event_unsubscribe, + .vidioc_try_decoder_cmd = vdec_try_decoder_cmd, + .vidioc_decoder_cmd = vdec_decoder_cmd, +}; + +static int vdec_set_properties(struct venus_inst *inst) +{ + struct vdec_controls *ctr = &inst->controls.dec; + struct venus_core *core = inst->core; + struct hfi_enable en = { .enable = 1 }; + u32 ptype; + int ret; + + if (core->res->hfi_version == HFI_VERSION_1XX) { + ptype = HFI_PROPERTY_PARAM_VDEC_CONTINUE_DATA_TRANSFER; + ret = hfi_session_set_property(inst, ptype, &en); + if (ret) + return ret; + } + + if (core->res->hfi_version == HFI_VERSION_3XX || + inst->cap_bufs_mode_dynamic) { + struct hfi_buffer_alloc_mode mode; + + ptype = HFI_PROPERTY_PARAM_BUFFER_ALLOC_MODE; + mode.type = HFI_BUFFER_OUTPUT; + mode.mode = HFI_BUFFER_MODE_DYNAMIC; + + ret = hfi_session_set_property(inst, ptype, &mode); + if (ret) + return ret; + } + + if (ctr->post_loop_deb_mode) { + ptype = HFI_PROPERTY_CONFIG_VDEC_POST_LOOP_DEBLOCKER; + en.enable = 1; + ret = hfi_session_set_property(inst, ptype, &en); + if (ret) + return ret; + } + + return 0; +} + +static int vdec_init_session(struct venus_inst *inst) +{ + int ret; + + ret = hfi_session_init(inst, inst->fmt_out->pixfmt); + if (ret) + return ret; + + ret = venus_helper_set_input_resolution(inst, inst->out_width, + inst->out_height); + if (ret) + goto deinit; + + ret = venus_helper_set_color_format(inst, inst->fmt_cap->pixfmt); + if (ret) + goto deinit; + + return 0; +deinit: + hfi_session_deinit(inst); + return ret; +} + +static int vdec_cap_num_buffers(struct venus_inst *inst, unsigned int *num) +{ + struct hfi_buffer_requirements bufreq; + int ret; + + ret = vdec_init_session(inst); + if (ret) + return ret; + + ret = venus_helper_get_bufreq(inst, HFI_BUFFER_OUTPUT, &bufreq); + + *num = bufreq.count_actual; + + hfi_session_deinit(inst); + + return ret; +} + +static int vdec_queue_setup(struct vb2_queue *q, + unsigned int *num_buffers, unsigned int *num_planes, + unsigned int sizes[], struct device *alloc_devs[]) +{ + struct venus_inst *inst = vb2_get_drv_priv(q); + unsigned int p, num; + int ret = 0; + + if (*num_planes) { + if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE && + *num_planes != inst->fmt_out->num_planes) + return -EINVAL; + + if (q->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE && + *num_planes != inst->fmt_cap->num_planes) + return -EINVAL; + + if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE && + sizes[0] < inst->input_buf_size) + return -EINVAL; + + if (q->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE && + sizes[0] < inst->output_buf_size) + return -EINVAL; + + return 0; + } + + switch (q->type) { + case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: + *num_planes = inst->fmt_out->num_planes; + sizes[0] = get_framesize_compressed(inst->out_width, + inst->out_height); + inst->input_buf_size = sizes[0]; + inst->num_input_bufs = *num_buffers; + break; + case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: + *num_planes = inst->fmt_cap->num_planes; + + ret = vdec_cap_num_buffers(inst, &num); + if (ret) + break; + + *num_buffers = max(*num_buffers, num); + + for (p = 0; p < *num_planes; p++) + sizes[p] = get_framesize_uncompressed(p, inst->width, + inst->height); + + inst->num_output_bufs = *num_buffers; + inst->output_buf_size = sizes[0]; + break; + default: + ret = -EINVAL; + break; + } + + return ret; +} + +static int vdec_verify_conf(struct venus_inst *inst) +{ + struct hfi_buffer_requirements bufreq; + int ret; + + if (!inst->num_input_bufs || !inst->num_output_bufs) + return -EINVAL; + + ret = venus_helper_get_bufreq(inst, HFI_BUFFER_OUTPUT, &bufreq); + if (ret) + return ret; + + if (inst->num_output_bufs < bufreq.count_actual || + inst->num_output_bufs < bufreq.count_min) + return -EINVAL; + + ret = venus_helper_get_bufreq(inst, HFI_BUFFER_INPUT, &bufreq); + if (ret) + return ret; + + if (inst->num_input_bufs < bufreq.count_min) + return -EINVAL; + + return 0; +} + +static int vdec_start_streaming(struct vb2_queue *q, unsigned int count) +{ + struct venus_inst *inst = vb2_get_drv_priv(q); + struct venus_core *core = inst->core; + u32 ptype; + int ret; + + mutex_lock(&inst->lock); + + if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) + inst->streamon_out = 1; + else + inst->streamon_cap = 1; + + if (!(inst->streamon_out & inst->streamon_cap)) { + mutex_unlock(&inst->lock); + return 0; + } + + venus_helper_init_instance(inst); + + inst->reconfig = false; + inst->sequence_cap = 0; + inst->sequence_out = 0; + inst->cmd_stop = false; + + ret = vdec_init_session(inst); + if (ret) + goto bufs_done; + + ret = vdec_set_properties(inst); + if (ret) + goto deinit_sess; + + if (core->res->hfi_version == HFI_VERSION_3XX) { + struct hfi_buffer_size_actual buf_sz; + + ptype = HFI_PROPERTY_PARAM_BUFFER_SIZE_ACTUAL; + buf_sz.type = HFI_BUFFER_OUTPUT; + buf_sz.size = inst->output_buf_size; + + ret = hfi_session_set_property(inst, ptype, &buf_sz); + if (ret) + goto deinit_sess; + } + + ret = vdec_verify_conf(inst); + if (ret) + goto deinit_sess; + + ret = venus_helper_set_num_bufs(inst, inst->num_input_bufs, + VB2_MAX_FRAME); + if (ret) + goto deinit_sess; + + ret = venus_helper_vb2_start_streaming(inst); + if (ret) + goto deinit_sess; + + mutex_unlock(&inst->lock); + + return 0; + +deinit_sess: + hfi_session_deinit(inst); +bufs_done: + venus_helper_buffers_done(inst, VB2_BUF_STATE_QUEUED); + if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) + inst->streamon_out = 0; + else + inst->streamon_cap = 0; + mutex_unlock(&inst->lock); + return ret; +} + +static const struct vb2_ops vdec_vb2_ops = { + .queue_setup = vdec_queue_setup, + .buf_init = venus_helper_vb2_buf_init, + .buf_prepare = venus_helper_vb2_buf_prepare, + .start_streaming = vdec_start_streaming, + .stop_streaming = venus_helper_vb2_stop_streaming, + .buf_queue = venus_helper_vb2_buf_queue, +}; + +static void vdec_buf_done(struct venus_inst *inst, unsigned int buf_type, + u32 tag, u32 bytesused, u32 data_offset, u32 flags, + u32 hfi_flags, u64 timestamp_us) +{ + enum vb2_buffer_state state = VB2_BUF_STATE_DONE; + struct vb2_v4l2_buffer *vbuf; + struct vb2_buffer *vb; + unsigned int type; + + if (buf_type == HFI_BUFFER_INPUT) + type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; + else + type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; + + vbuf = venus_helper_find_buf(inst, type, tag); + if (!vbuf) + return; + + vbuf->flags = flags; + vbuf->field = V4L2_FIELD_NONE; + + if (type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { + vb = &vbuf->vb2_buf; + vb->planes[0].bytesused = + max_t(unsigned int, inst->output_buf_size, bytesused); + vb->planes[0].data_offset = data_offset; + vb->timestamp = timestamp_us * NSEC_PER_USEC; + vbuf->sequence = inst->sequence_cap++; + + if (inst->cmd_stop) { + vbuf->flags |= V4L2_BUF_FLAG_LAST; + inst->cmd_stop = false; + } + + if (vbuf->flags & V4L2_BUF_FLAG_LAST) { + const struct v4l2_event ev = { .type = V4L2_EVENT_EOS }; + + v4l2_event_queue_fh(&inst->fh, &ev); + } + } else { + vbuf->sequence = inst->sequence_out++; + } + + if (hfi_flags & HFI_BUFFERFLAG_READONLY) + venus_helper_acquire_buf_ref(vbuf); + + if (hfi_flags & HFI_BUFFERFLAG_DATACORRUPT) + state = VB2_BUF_STATE_ERROR; + + v4l2_m2m_buf_done(vbuf, state); +} + +static void vdec_event_notify(struct venus_inst *inst, u32 event, + struct hfi_event_data *data) +{ + struct venus_core *core = inst->core; + struct device *dev = core->dev_dec; + static const struct v4l2_event ev = { + .type = V4L2_EVENT_SOURCE_CHANGE, + .u.src_change.changes = V4L2_EVENT_SRC_CH_RESOLUTION }; + + switch (event) { + case EVT_SESSION_ERROR: + inst->session_error = true; + dev_err(dev, "dec: event session error %x\n", inst->error); + break; + case EVT_SYS_EVENT_CHANGE: + switch (data->event_type) { + case HFI_EVENT_DATA_SEQUENCE_CHANGED_SUFFICIENT_BUF_RESOURCES: + hfi_session_continue(inst); + dev_dbg(dev, "event sufficient resources\n"); + break; + case HFI_EVENT_DATA_SEQUENCE_CHANGED_INSUFFICIENT_BUF_RESOURCES: + inst->reconfig_height = data->height; + inst->reconfig_width = data->width; + inst->reconfig = true; + + v4l2_event_queue_fh(&inst->fh, &ev); + + dev_dbg(dev, "event not sufficient resources (%ux%u)\n", + data->width, data->height); + break; + case HFI_EVENT_RELEASE_BUFFER_REFERENCE: + venus_helper_release_buf_ref(inst, data->tag); + break; + default: + break; + } + break; + default: + break; + } +} + +static const struct hfi_inst_ops vdec_hfi_ops = { + .buf_done = vdec_buf_done, + .event_notify = vdec_event_notify, +}; + +static void vdec_inst_init(struct venus_inst *inst) +{ + inst->fmt_out = &vdec_formats[6]; + inst->fmt_cap = &vdec_formats[0]; + inst->width = 1280; + inst->height = ALIGN(720, 32); + inst->out_width = 1280; + inst->out_height = 720; + inst->fps = 30; + inst->timeperframe.numerator = 1; + inst->timeperframe.denominator = 30; + + inst->cap_width.min = 64; + inst->cap_width.max = 1920; + if (inst->core->res->hfi_version == HFI_VERSION_3XX) + inst->cap_width.max = 3840; + inst->cap_width.step_size = 1; + inst->cap_height.min = 64; + inst->cap_height.max = ALIGN(1080, 32); + if (inst->core->res->hfi_version == HFI_VERSION_3XX) + inst->cap_height.max = ALIGN(2160, 32); + inst->cap_height.step_size = 1; + inst->cap_framerate.min = 1; + inst->cap_framerate.max = 30; + inst->cap_framerate.step_size = 1; + inst->cap_mbs_per_frame.min = 16; + inst->cap_mbs_per_frame.max = 8160; +} + +static const struct v4l2_m2m_ops vdec_m2m_ops = { + .device_run = venus_helper_m2m_device_run, + .job_abort = venus_helper_m2m_job_abort, +}; + +static int m2m_queue_init(void *priv, struct vb2_queue *src_vq, + struct vb2_queue *dst_vq) +{ + struct venus_inst *inst = priv; + int ret; + + src_vq->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; + src_vq->io_modes = VB2_MMAP | VB2_DMABUF; + src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; + src_vq->ops = &vdec_vb2_ops; + src_vq->mem_ops = &vb2_dma_sg_memops; + src_vq->drv_priv = inst; + src_vq->buf_struct_size = sizeof(struct venus_buffer); + src_vq->allow_zero_bytesused = 1; + src_vq->min_buffers_needed = 1; + src_vq->dev = inst->core->dev; + ret = vb2_queue_init(src_vq); + if (ret) + return ret; + + dst_vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; + dst_vq->io_modes = VB2_MMAP | VB2_DMABUF; + dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; + dst_vq->ops = &vdec_vb2_ops; + dst_vq->mem_ops = &vb2_dma_sg_memops; + dst_vq->drv_priv = inst; + dst_vq->buf_struct_size = sizeof(struct venus_buffer); + dst_vq->allow_zero_bytesused = 1; + dst_vq->min_buffers_needed = 1; + dst_vq->dev = inst->core->dev; + ret = vb2_queue_init(dst_vq); + if (ret) { + vb2_queue_release(src_vq); + return ret; + } + + return 0; +} + +static int vdec_open(struct file *file) +{ + struct venus_core *core = video_drvdata(file); + struct venus_inst *inst; + int ret; + + inst = kzalloc(sizeof(*inst), GFP_KERNEL); + if (!inst) + return -ENOMEM; + + INIT_LIST_HEAD(&inst->registeredbufs); + INIT_LIST_HEAD(&inst->internalbufs); + INIT_LIST_HEAD(&inst->list); + mutex_init(&inst->lock); + + inst->core = core; + inst->session_type = VIDC_SESSION_TYPE_DEC; + + venus_helper_init_instance(inst); + + ret = pm_runtime_get_sync(core->dev_dec); + if (ret < 0) + goto err_free_inst; + + ret = vdec_ctrl_init(inst); + if (ret) + goto err_put_sync; + + ret = hfi_session_create(inst, &vdec_hfi_ops); + if (ret) + goto err_ctrl_deinit; + + vdec_inst_init(inst); + + /* + * create m2m device for every instance, the m2m context scheduling + * is made by firmware side so we do not need to care about. + */ + inst->m2m_dev = v4l2_m2m_init(&vdec_m2m_ops); + if (IS_ERR(inst->m2m_dev)) { + ret = PTR_ERR(inst->m2m_dev); + goto err_session_destroy; + } + + inst->m2m_ctx = v4l2_m2m_ctx_init(inst->m2m_dev, inst, m2m_queue_init); + if (IS_ERR(inst->m2m_ctx)) { + ret = PTR_ERR(inst->m2m_ctx); + goto err_m2m_release; + } + + v4l2_fh_init(&inst->fh, core->vdev_dec); + + inst->fh.ctrl_handler = &inst->ctrl_handler; + v4l2_fh_add(&inst->fh); + inst->fh.m2m_ctx = inst->m2m_ctx; + file->private_data = &inst->fh; + + return 0; + +err_m2m_release: + v4l2_m2m_release(inst->m2m_dev); +err_session_destroy: + hfi_session_destroy(inst); +err_ctrl_deinit: + vdec_ctrl_deinit(inst); +err_put_sync: + pm_runtime_put_sync(core->dev_dec); +err_free_inst: + kfree(inst); + return ret; +} + +static int vdec_close(struct file *file) +{ + struct venus_inst *inst = to_inst(file); + + v4l2_m2m_ctx_release(inst->m2m_ctx); + v4l2_m2m_release(inst->m2m_dev); + vdec_ctrl_deinit(inst); + hfi_session_destroy(inst); + mutex_destroy(&inst->lock); + v4l2_fh_del(&inst->fh); + v4l2_fh_exit(&inst->fh); + kfree(inst); + + pm_runtime_put_sync(inst->core->dev_dec); + return 0; +} + +static const struct v4l2_file_operations vdec_fops = { + .owner = THIS_MODULE, + .open = vdec_open, + .release = vdec_close, + .unlocked_ioctl = video_ioctl2, + .poll = v4l2_m2m_fop_poll, + .mmap = v4l2_m2m_fop_mmap, +#ifdef CONFIG_COMPAT + .compat_ioctl32 = v4l2_compat_ioctl32, +#endif +}; + +static int vdec_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct video_device *vdev; + struct venus_core *core; + int ret; + + if (!dev->parent) + return -EPROBE_DEFER; + + core = dev_get_drvdata(dev->parent); + if (!core) + return -EPROBE_DEFER; + + if (core->res->hfi_version == HFI_VERSION_3XX) { + core->core0_clk = devm_clk_get(dev, "core"); + if (IS_ERR(core->core0_clk)) + return PTR_ERR(core->core0_clk); + } + + platform_set_drvdata(pdev, core); + + vdev = video_device_alloc(); + if (!vdev) + return -ENOMEM; + + vdev->release = video_device_release; + vdev->fops = &vdec_fops; + vdev->ioctl_ops = &vdec_ioctl_ops; + vdev->vfl_dir = VFL_DIR_M2M; + vdev->v4l2_dev = &core->v4l2_dev; + vdev->device_caps = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_STREAMING; + + ret = video_register_device(vdev, VFL_TYPE_GRABBER, -1); + if (ret) + goto err_vdev_release; + + core->vdev_dec = vdev; + core->dev_dec = dev; + + video_set_drvdata(vdev, core); + pm_runtime_enable(dev); + + return 0; + +err_vdev_release: + video_device_release(vdev); + return ret; +} + +static int vdec_remove(struct platform_device *pdev) +{ + struct venus_core *core = dev_get_drvdata(pdev->dev.parent); + + video_unregister_device(core->vdev_dec); + pm_runtime_disable(core->dev_dec); + + return 0; +} + +#ifdef CONFIG_PM +static int vdec_runtime_suspend(struct device *dev) +{ + struct venus_core *core = dev_get_drvdata(dev); + + if (core->res->hfi_version == HFI_VERSION_1XX) + return 0; + + writel(0, core->base + WRAPPER_VDEC_VCODEC_POWER_CONTROL); + clk_disable_unprepare(core->core0_clk); + writel(1, core->base + WRAPPER_VDEC_VCODEC_POWER_CONTROL); + + return 0; +} + +static int vdec_runtime_resume(struct device *dev) +{ + struct venus_core *core = dev_get_drvdata(dev); + int ret; + + if (core->res->hfi_version == HFI_VERSION_1XX) + return 0; + + writel(0, core->base + WRAPPER_VDEC_VCODEC_POWER_CONTROL); + ret = clk_prepare_enable(core->core0_clk); + writel(1, core->base + WRAPPER_VDEC_VCODEC_POWER_CONTROL); + + return ret; +} +#endif + +static const struct dev_pm_ops vdec_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, + pm_runtime_force_resume) + SET_RUNTIME_PM_OPS(vdec_runtime_suspend, vdec_runtime_resume, NULL) +}; + +static const struct of_device_id vdec_dt_match[] = { + { .compatible = "venus-decoder" }, + { } +}; +MODULE_DEVICE_TABLE(of, vdec_dt_match); + +static struct platform_driver qcom_venus_dec_driver = { + .probe = vdec_probe, + .remove = vdec_remove, + .driver = { + .name = "qcom-venus-decoder", + .of_match_table = vdec_dt_match, + .pm = &vdec_pm_ops, + }, +}; +module_platform_driver(qcom_venus_dec_driver); + +MODULE_ALIAS("platform:qcom-venus-decoder"); +MODULE_DESCRIPTION("Qualcomm Venus video decoder driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/media/platform/qcom/venus/vdec.h b/drivers/media/platform/qcom/venus/vdec.h new file mode 100644 index 000000000000..84b672c54d02 --- /dev/null +++ b/drivers/media/platform/qcom/venus/vdec.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. + * Copyright (C) 2017 Linaro Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ +#ifndef __VENUS_VDEC_H__ +#define __VENUS_VDEC_H__ + +struct venus_inst; + +int vdec_ctrl_init(struct venus_inst *inst); +void vdec_ctrl_deinit(struct venus_inst *inst); + +#endif diff --git a/drivers/media/platform/qcom/venus/vdec_ctrls.c b/drivers/media/platform/qcom/venus/vdec_ctrls.c new file mode 100644 index 000000000000..1045fc5b4925 --- /dev/null +++ b/drivers/media/platform/qcom/venus/vdec_ctrls.c @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. + * Copyright (C) 2017 Linaro Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ +#include +#include + +#include "core.h" +#include "vdec.h" + +static int vdec_op_s_ctrl(struct v4l2_ctrl *ctrl) +{ + struct venus_inst *inst = ctrl_to_inst(ctrl); + struct vdec_controls *ctr = &inst->controls.dec; + + switch (ctrl->id) { + case V4L2_CID_MPEG_VIDEO_DECODER_MPEG4_DEBLOCK_FILTER: + ctr->post_loop_deb_mode = ctrl->val; + break; + case V4L2_CID_MPEG_VIDEO_H264_PROFILE: + case V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE: + case V4L2_CID_MPEG_VIDEO_VPX_PROFILE: + ctr->profile = ctrl->val; + break; + case V4L2_CID_MPEG_VIDEO_H264_LEVEL: + case V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL: + ctr->level = ctrl->val; + break; + default: + return -EINVAL; + } + + return 0; +} + +static int vdec_op_g_volatile_ctrl(struct v4l2_ctrl *ctrl) +{ + struct venus_inst *inst = ctrl_to_inst(ctrl); + struct vdec_controls *ctr = &inst->controls.dec; + union hfi_get_property hprop; + u32 ptype = HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT; + int ret; + + switch (ctrl->id) { + case V4L2_CID_MPEG_VIDEO_H264_PROFILE: + case V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE: + case V4L2_CID_MPEG_VIDEO_VPX_PROFILE: + ret = hfi_session_get_property(inst, ptype, &hprop); + if (!ret) + ctr->profile = hprop.profile_level.profile; + ctrl->val = ctr->profile; + break; + case V4L2_CID_MPEG_VIDEO_H264_LEVEL: + case V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL: + ret = hfi_session_get_property(inst, ptype, &hprop); + if (!ret) + ctr->level = hprop.profile_level.level; + ctrl->val = ctr->level; + break; + case V4L2_CID_MPEG_VIDEO_DECODER_MPEG4_DEBLOCK_FILTER: + ctrl->val = ctr->post_loop_deb_mode; + break; + default: + return -EINVAL; + }; + + return 0; +} + +static const struct v4l2_ctrl_ops vdec_ctrl_ops = { + .s_ctrl = vdec_op_s_ctrl, + .g_volatile_ctrl = vdec_op_g_volatile_ctrl, +}; + +int vdec_ctrl_init(struct venus_inst *inst) +{ + struct v4l2_ctrl *ctrl; + int ret; + + ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 6); + if (ret) + return ret; + + ctrl = v4l2_ctrl_new_std_menu(&inst->ctrl_handler, &vdec_ctrl_ops, + V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE, + V4L2_MPEG_VIDEO_MPEG4_PROFILE_ADVANCED_CODING_EFFICIENCY, + ~((1 << V4L2_MPEG_VIDEO_MPEG4_PROFILE_SIMPLE) | + (1 << V4L2_MPEG_VIDEO_MPEG4_PROFILE_ADVANCED_SIMPLE)), + V4L2_MPEG_VIDEO_MPEG4_PROFILE_SIMPLE); + if (ctrl) + ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE; + + ctrl = v4l2_ctrl_new_std_menu(&inst->ctrl_handler, &vdec_ctrl_ops, + V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL, + V4L2_MPEG_VIDEO_MPEG4_LEVEL_5, + 0, V4L2_MPEG_VIDEO_MPEG4_LEVEL_0); + if (ctrl) + ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE; + + ctrl = v4l2_ctrl_new_std_menu(&inst->ctrl_handler, &vdec_ctrl_ops, + V4L2_CID_MPEG_VIDEO_H264_PROFILE, + V4L2_MPEG_VIDEO_H264_PROFILE_MULTIVIEW_HIGH, + ~((1 << V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE) | + (1 << V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_BASELINE) | + (1 << V4L2_MPEG_VIDEO_H264_PROFILE_MAIN) | + (1 << V4L2_MPEG_VIDEO_H264_PROFILE_HIGH) | + (1 << V4L2_MPEG_VIDEO_H264_PROFILE_STEREO_HIGH) | + (1 << V4L2_MPEG_VIDEO_H264_PROFILE_MULTIVIEW_HIGH)), + V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE); + if (ctrl) + ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE; + + ctrl = v4l2_ctrl_new_std_menu(&inst->ctrl_handler, &vdec_ctrl_ops, + V4L2_CID_MPEG_VIDEO_H264_LEVEL, + V4L2_MPEG_VIDEO_H264_LEVEL_5_1, + 0, V4L2_MPEG_VIDEO_H264_LEVEL_1_0); + if (ctrl) + ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE; + + ctrl = v4l2_ctrl_new_std(&inst->ctrl_handler, &vdec_ctrl_ops, + V4L2_CID_MPEG_VIDEO_VPX_PROFILE, 0, 3, 1, 0); + if (ctrl) + ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE; + + v4l2_ctrl_new_std(&inst->ctrl_handler, &vdec_ctrl_ops, + V4L2_CID_MPEG_VIDEO_DECODER_MPEG4_DEBLOCK_FILTER, 0, 1, 1, 0); + + ret = inst->ctrl_handler.error; + if (ret) { + v4l2_ctrl_handler_free(&inst->ctrl_handler); + return ret; + } + + return 0; +} + +void vdec_ctrl_deinit(struct venus_inst *inst) +{ + v4l2_ctrl_handler_free(&inst->ctrl_handler); +} From patchwork Mon Jun 12 16:27:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 103656 Delivered-To: patch@linaro.org Received: by 10.182.29.35 with SMTP id g3csp77279obh; Mon, 12 Jun 2017 09:31:00 -0700 (PDT) X-Received: by 10.101.85.69 with SMTP id t5mr57895507pgr.201.1497285060383; Mon, 12 Jun 2017 09:31:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497285060; cv=none; d=google.com; s=arc-20160816; b=Shp0HpWQJZZ2jp+GspGSRNa0aWUJC57mqM2h9y/lIUbaaacPjJPgC4MYrtQOussOan GWHh6s647P84kbFFE3JyO9+sle78NcvWwvXng9YWogBr88ZCILcoA8SROtiwMPCdr8am JnMT9v7T/juKXgCh29Fgj77M35P9Kfgk5PcObBCyUdNzMPnafypLMm++Uoffne5sOXck Zp8cdb/UoJ21OFzL8xHn5NcJeGEzujjPXtYYG18tSPe0nBwALEfklmgVT5GjakN08DMX haEkpp4bnvgUfrHPfC3hUTzMtuEP94ei3KFNsvaZSZ/Fx4Eszcsmg8vKZOA5bmP+zbTR t8BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=PTyoPZBrq6iZva4zHnyG6otP9L/TlXnfZ3rg7uBAhNU=; b=o6EJ0pKnpL7y+voSV5AlEtiWieXbMPWeLvS4zsK+Lv4a05ujPTTu2Wm2RzmS1QsUcc C9wjXxGHu5VHzmubsSiMF9rwvqwm52xcQDRh2EtqkDQf20Quyueac5HpSt5kXuUjD2Sm E7fqVNxisD+/8q78hEthXX7lhfcnyuvblgPPWDPDmYQE/3bjaK4W2tRVOZcBXRQi1vkc vjmPKJ/kZC2iDsfcwnUZ6ks70iIPBvLiFl6IXEc/pelb6325JHZHuZNTc0hJe7yMuwGy jVDjHFu1zuXBuAddrg+Ya9BTuYnGSwLt5i/s1v4vLdhHaPQ5qVGn9zre5J35mQemQnFn khRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 142si13486384pgg.72.2017.06.12.09.30.59; Mon, 12 Jun 2017 09:31:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932123AbdFLQaJ (ORCPT + 25 others); Mon, 12 Jun 2017 12:30:09 -0400 Received: from mail-wr0-f175.google.com ([209.85.128.175]:33218 "EHLO mail-wr0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754877AbdFLQaC (ORCPT ); Mon, 12 Jun 2017 12:30:02 -0400 Received: by mail-wr0-f175.google.com with SMTP id v104so101965608wrb.0 for ; Mon, 12 Jun 2017 09:30:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PTyoPZBrq6iZva4zHnyG6otP9L/TlXnfZ3rg7uBAhNU=; b=WOn/AlsWU+lE+w1zqRCEOiJiu/llvNiN8lFrZEriXoHGbeW48aIUsZqMYXsj1Pe6S/ LGREbEt3Ohn6EUkKBjz93LJaL7Lbm3mrT/xLQ+eQkVMKh+rF6i52ifArT5kNccQVzaFt id+FhyRFbN3DKJeKdqoimVdwg0e02yEF1uOnc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PTyoPZBrq6iZva4zHnyG6otP9L/TlXnfZ3rg7uBAhNU=; b=VVamjroPYz0JzWQ8PyDZ4IjpeST23+ipSM9ixMYSr2RFVLpUiBjVtcLqVbze+uwNAr FcOLyD33D5HK4xA1UquqeStDLw6CcO4DlwQJepA63Nhs+wlNvbNphwXlWQcMg3TQJZuo kmeRXTBEIFJflslsXlDL0GOXxyCMsTxAH871XDm/fcKVycd30ubVx+edE/qCxevEYyan eDIkSAIgi7R4JrNRPH9F/T4/CJt2M2GD9bSUwZKeUAH/P+JyLK2PhpcptF2x277dYP3w rNg7Ipc48jRPo8GT8YJaYrp4Cx1nfpVr6S4vtZmW68ezISIX8JCU/ijrKBa7lu+B/NjG VXyg== X-Gm-Message-State: AODbwcDVVsH/8tONFwxCd84y+J/hNmrLQvNGTmyXN8yXkndvLqWfS3+l bKVuN4lyAsaL/V66 X-Received: by 10.223.138.194 with SMTP id z2mr8825821wrz.66.1497284989673; Mon, 12 Jun 2017 09:29:49 -0700 (PDT) Received: from mms-0440.qualcomm.mm-sol.com ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id 49sm14493531wrz.8.2017.06.12.09.29.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 12 Jun 2017 09:29:49 -0700 (PDT) From: Stanimir Varbanov To: Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Stanimir Varbanov Subject: [PATCH v10 11/18] media: venus: hfi_cmds: fix variable dereferenced before check Date: Mon, 12 Jun 2017 19:27:48 +0300 Message-Id: <1497284875-19999-12-git-send-email-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497284875-19999-1-git-send-email-stanimir.varbanov@linaro.org> References: <1497284875-19999-1-git-send-email-stanimir.varbanov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This fixes a warning found when building the driver with gcc7: drivers/media/platform/qcom/venus/hfi_cmds.c:415 pkt_session_set_property_1x() warn: variable dereferenced before check 'pkt' (see line 412) drivers/media/platform/qcom/venus/hfi_cmds.c:1177 pkt_session_set_property_3xx() warn: variable dereferenced before check 'pkt' (see line 1174) Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/hfi_cmds.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/media/platform/qcom/venus/hfi_cmds.c b/drivers/media/platform/qcom/venus/hfi_cmds.c index dad41a6af42e..b83c5b8ddccb 100644 --- a/drivers/media/platform/qcom/venus/hfi_cmds.c +++ b/drivers/media/platform/qcom/venus/hfi_cmds.c @@ -409,12 +409,14 @@ static int pkt_session_get_property_1x(struct hfi_session_get_property_pkt *pkt, static int pkt_session_set_property_1x(struct hfi_session_set_property_pkt *pkt, void *cookie, u32 ptype, void *pdata) { - void *prop_data = &pkt->data[1]; + void *prop_data; int ret = 0; if (!pkt || !cookie || !pdata) return -EINVAL; + prop_data = &pkt->data[1]; + pkt->shdr.hdr.size = sizeof(*pkt); pkt->shdr.hdr.pkt_type = HFI_CMD_SESSION_SET_PROPERTY; pkt->shdr.session_id = hash32_ptr(cookie); @@ -1171,12 +1173,14 @@ static int pkt_session_set_property_3xx(struct hfi_session_set_property_pkt *pkt, void *cookie, u32 ptype, void *pdata) { - void *prop_data = &pkt->data[1]; + void *prop_data; int ret = 0; if (!pkt || !cookie || !pdata) return -EINVAL; + prop_data = &pkt->data[1]; + pkt->shdr.hdr.size = sizeof(*pkt); pkt->shdr.hdr.pkt_type = HFI_CMD_SESSION_SET_PROPERTY; pkt->shdr.session_id = hash32_ptr(cookie); From patchwork Mon Jun 12 16:27:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 103657 Delivered-To: patch@linaro.org Received: by 10.182.29.35 with SMTP id g3csp77282obh; Mon, 12 Jun 2017 09:31:00 -0700 (PDT) X-Received: by 10.84.215.23 with SMTP id k23mr58233219pli.104.1497285060841; Mon, 12 Jun 2017 09:31:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497285060; cv=none; d=google.com; s=arc-20160816; b=FtVLhWA5uBedIIzEhaIp7gXkwr3snA9dMEBC5JIwjywohxPPFjjlw7PiYZS0Vs69tb w+tS1t0cYC33BeHC2BFEFzhYmi/av6TKK/uZdvzYuROr3a07JaIjUsSERwkKyxGpLyWH kpuwZpi2wXYvFIk7YhBQvis5YzEwwbd12MF3TxKkWo16N9LIRKM+deWXqlSRS0qXZagI gV9K+XsnP6IaQWGb/ieQAldizrH4KTUth4lAobxwlWzufadGKD9WFEA5/fvbm+BmmYpS 5Snb3JUP43rVOJasx1eC/p0PoOR8aWFPof/uKtSxh3Bkjh+30O6P8/fZnR3vtmUjTmKy oPGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=LddNM0B7BF2Q1NR9owPFwmfghKr/CobKCgYvCgn0VcA=; b=DNjPgw179d9t+einhrNCT4iJmWvPaVTG9dwxHRHn/qs9MLos+YXMhS195aaIZ5yOpb 6yN8dVgVrGYSQHVfUc9Ia7B7pVVBkkpsGpNYKn+BPwrwzDGpjgIvuQ8WdrBCE07yiFcF 66KY/Uly4+lz4IFt2+aSRx8EQf570lb5sI7skDC1RDKdeu9vGEYuhmrYK3LaaowrY+Ok JRxgdZXJodb1gXIOw/+v6dWbGNC9a0R1pu06mScuu9hxnYWpAU4AFLAWPtW3c13yHxqs b9nLQrSdkWgMOPp46yuWetInPe7gZjMy8xO+Gwta7m3yn7iwFH9aQvtCxHAFe/dAepWx r92g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 142si13486384pgg.72.2017.06.12.09.31.00; Mon, 12 Jun 2017 09:31:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754829AbdFLQa4 (ORCPT + 25 others); Mon, 12 Jun 2017 12:30:56 -0400 Received: from mail-wr0-f172.google.com ([209.85.128.172]:33965 "EHLO mail-wr0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754915AbdFLQaJ (ORCPT ); Mon, 12 Jun 2017 12:30:09 -0400 Received: by mail-wr0-f172.google.com with SMTP id g76so101845637wrd.1 for ; Mon, 12 Jun 2017 09:30:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LddNM0B7BF2Q1NR9owPFwmfghKr/CobKCgYvCgn0VcA=; b=bAAlCTgsIBpJQGPhPlOjby8HlVU+w5KWMZ/W+3y1okBH1bIeP2uhy/ddbZXAOCzUtH 0xM9IY2IS0TEq+GKjU3OM2d9c9gGOWI+RRViv5EUMBxTeCNlpoII/MiJqgGFkcmROOZc Mhew3ubpm7CivP8ioukBalKPFMpBoa/rPAJNQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LddNM0B7BF2Q1NR9owPFwmfghKr/CobKCgYvCgn0VcA=; b=SxMjUICYSN5vpR+1B86I1xiMzwyTa22cyYhkvxyJbxIARBOo5BjEWr5DvwHyVjp24O Y0CngEzJX8W76ev2x+VxrA9aTD7yOLQcd3KTF5dbTu4He4W8DKO2MuG5PsoQ2Ldb4jY7 c2RpXAP9GJPpfa9z6JuYqgsv2Hk51QtpszCZJHQ0OGQDcXgjBFkDpsuT754WyHPu7IVi KHUDeqpU5Gz3LVnE4mJtadnFzLa51QKo8hEMv9rZ3oTLMM0AQIVWP3AV8zCDzRgY71oy O6a7YaSaYFHR5YF1Uc1v1j/BLzTy+nBK2KRy809lUaGVajhRwUdoj0YT3H2b8bHkS3ay laFg== X-Gm-Message-State: AKS2vOwsQjOp1OUm5pFALFGFLMQBLGRIKrx3kGjkMACd4fKvxAPWBqfp 6QAeAEgW0kbTcFIF X-Received: by 10.223.163.93 with SMTP id d29mr8358139wrb.95.1497284996839; Mon, 12 Jun 2017 09:29:56 -0700 (PDT) Received: from mms-0440.qualcomm.mm-sol.com ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id 49sm14493531wrz.8.2017.06.12.09.29.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 12 Jun 2017 09:29:56 -0700 (PDT) From: Stanimir Varbanov To: Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Stanimir Varbanov Subject: [PATCH v10 15/18] media: venus: vdec: fix compile error in vdec_close Date: Mon, 12 Jun 2017 19:27:52 +0300 Message-Id: <1497284875-19999-16-git-send-email-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497284875-19999-1-git-send-email-stanimir.varbanov@linaro.org> References: <1497284875-19999-1-git-send-email-stanimir.varbanov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This fixes the following compile error ocured when building with gcc7: drivers/media/platform/qcom/venus/vdec.c:1022 vdec_close() error: dereferencing freed memory 'inst' by moving kfree as a last call. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/vdec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index 96e7e7e71e5f..594315b55b1f 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -1017,9 +1017,10 @@ static int vdec_close(struct file *file) mutex_destroy(&inst->lock); v4l2_fh_del(&inst->fh); v4l2_fh_exit(&inst->fh); - kfree(inst); pm_runtime_put_sync(inst->core->dev_dec); + + kfree(inst); return 0; } From patchwork Mon Jun 12 16:27:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 103658 Delivered-To: patch@linaro.org Received: by 10.182.29.35 with SMTP id g3csp77768obh; Mon, 12 Jun 2017 09:31:42 -0700 (PDT) X-Received: by 10.99.66.5 with SMTP id p5mr58141036pga.107.1497285102004; Mon, 12 Jun 2017 09:31:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497285101; cv=none; d=google.com; s=arc-20160816; b=dw0eBPnkZy+vYHUtBUjezjOMoFnjrrmF4nqTt2H4tKPVVUXKzi8tMcJ1/2MyPUzb4V atv/D9YlwYyGD95yHGr5ZNJUM9Qosrk7U8t+EJbV6JyfzL7MljmEeaYE924ZYxFrTzlm oeNZ4jItiTfWFLDLd3w2GJs8Miu5wHM8M+/Wo+27CFm690wBS7+zv4R6t8mXDl4onAHg XM7OxIzepNcpaJ/qJxwEBjVfZmhHiMpA0lHAjUYyCg8cv6Qzj2Cl4mrp3Wu30kPVamKe vo+8ZXyRcHZ6BUI88ZUqunf61DgyGAQFw2RzTIKzj+HlUYmO35aoR7UuiH7v4e2Xtva4 Hjaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=xGjG4s7f9q81WO34hY9cUv5xD2E6LJWqeseOjZYopZU=; b=nvi8G16zOVtMbRr+49lc2cD7rrvjIZN9EAVwq5kF20w14CtMMBByZ8hPMzjdDMUeoW RfMqSKp6qfFVm5khns7y4Nu+rqHgw8YBXwSG17g5hJUkLHjs5T1Q6YcI8paa4ZM4VhiH svpslWY7Ri4Gd+2ZcHksUialNSGCgWieQDLNDqEFl5KvHOVQJ4IToMo0Ho1owdyDeLWU 1eTOj8wbm7a4whoRprOQYyEk+qaeuNxnXkubeu8Lmyr7yxPLfiI2zwaRGmifLtnAINbR ZcRp4XawhYyIxqpAMcU+ETc7YyR8Qm8LwlawY7iYORo0NHJnNaxfkqeeSUqGOHDaHeI8 rv7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r90si7259987pfe.5.2017.06.12.09.31.41; Mon, 12 Jun 2017 09:31:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932120AbdFLQaH (ORCPT + 25 others); Mon, 12 Jun 2017 12:30:07 -0400 Received: from mail-wr0-f177.google.com ([209.85.128.177]:34012 "EHLO mail-wr0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754249AbdFLQaE (ORCPT ); Mon, 12 Jun 2017 12:30:04 -0400 Received: by mail-wr0-f177.google.com with SMTP id g76so101848090wrd.1 for ; Mon, 12 Jun 2017 09:30:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xGjG4s7f9q81WO34hY9cUv5xD2E6LJWqeseOjZYopZU=; b=eU8LkCq7jIvVpVsNEIX82HItdJO6R87qaSMGVz/P6Oi1IM4mINC9HSusNxAbRNZjFh 1eVcmzn/FUwOr48E76OTnRKHETKhxRfL9PZrhx/r+J3lQcMB0aJZmyYrYLM01sGz6RAp IR1q3ryfpU5lIlKiVNf+G5IAhqgqTwr0GaZoc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xGjG4s7f9q81WO34hY9cUv5xD2E6LJWqeseOjZYopZU=; b=Z2/7jEs+hmtK4nLf2zKuhfn9ObumkeqFkZKPV5DmuXvtxp+v4QdcJ8375314BXAf00 Xv1jPRkDvIU8FnBIzG4X93cEPhPJmn8Qwmvz+f/dvKNiQtjU0Hs02DjjPOJvSCuuehp1 MkO20mexzR2GgnTq1Gk7xoGPPoaVwPRnwmE1NX6UY/5RZZc3encTRGCaZrMDPHE5uyhD i2hD83M1zYblABok4ctoKajL1n22gZNIFROdV0f8ZfhSo2AKNxjYQhR2mbrtQWjaqRF3 GmJShGHauTTEtx5HTLZNoxSRTahKLmeQHg02fumSnSORZLUXFkbbyg/cMNPVF62QB+Zz HWUQ== X-Gm-Message-State: AODbwcAvXeUyUoftujcrIwzyRqzBoL9l/euBKf9AW4KLg/QDi8+grLZw lvccYwjl9AFoarqr+/q6lg== X-Received: by 10.28.40.198 with SMTP id o189mr8517740wmo.102.1497285001066; Mon, 12 Jun 2017 09:30:01 -0700 (PDT) Received: from mms-0440.qualcomm.mm-sol.com ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id 49sm14493531wrz.8.2017.06.12.09.30.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 12 Jun 2017 09:30:00 -0700 (PDT) From: Stanimir Varbanov To: Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Stanimir Varbanov Subject: [PATCH v10 17/18] media: venus: vdec: add support for min buffers for capture Date: Mon, 12 Jun 2017 19:27:54 +0300 Message-Id: <1497284875-19999-18-git-send-email-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497284875-19999-1-git-send-email-stanimir.varbanov@linaro.org> References: <1497284875-19999-1-git-send-email-stanimir.varbanov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This adds support for V4L2_CID_MIN_BUFFERS_FOR_CAPTURE get control in venus decoder, it is usable in case when the userspace wants to know minimum capture buffers before calling request_buf for capture queue in mem2mem drivers. Also this will fix an issue found gstreamer v4l2videodec element, i.e. the video decoder element cannot continue because the buffers are insufficient. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/vdec.c | 7 +++++++ drivers/media/platform/qcom/venus/vdec_ctrls.c | 10 +++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index 594315b55b1f..eb0c1c51cfef 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -627,6 +627,12 @@ static int vdec_queue_setup(struct vb2_queue *q, inst->out_height); inst->input_buf_size = sizes[0]; inst->num_input_bufs = *num_buffers; + + ret = vdec_cap_num_buffers(inst, &num); + if (ret) + break; + + inst->num_output_bufs = num; break; case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: *num_planes = inst->fmt_cap->num_planes; @@ -951,6 +957,7 @@ static int vdec_open(struct file *file) inst->core = core; inst->session_type = VIDC_SESSION_TYPE_DEC; + inst->num_output_bufs = 1; venus_helper_init_instance(inst); diff --git a/drivers/media/platform/qcom/venus/vdec_ctrls.c b/drivers/media/platform/qcom/venus/vdec_ctrls.c index 1045fc5b4925..032839bbc967 100644 --- a/drivers/media/platform/qcom/venus/vdec_ctrls.c +++ b/drivers/media/platform/qcom/venus/vdec_ctrls.c @@ -70,6 +70,9 @@ static int vdec_op_g_volatile_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_MPEG_VIDEO_DECODER_MPEG4_DEBLOCK_FILTER: ctrl->val = ctr->post_loop_deb_mode; break; + case V4L2_CID_MIN_BUFFERS_FOR_CAPTURE: + ctrl->val = inst->num_output_bufs; + break; default: return -EINVAL; }; @@ -87,7 +90,7 @@ int vdec_ctrl_init(struct venus_inst *inst) struct v4l2_ctrl *ctrl; int ret; - ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 6); + ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 7); if (ret) return ret; @@ -135,6 +138,11 @@ int vdec_ctrl_init(struct venus_inst *inst) v4l2_ctrl_new_std(&inst->ctrl_handler, &vdec_ctrl_ops, V4L2_CID_MPEG_VIDEO_DECODER_MPEG4_DEBLOCK_FILTER, 0, 1, 1, 0); + ctrl = v4l2_ctrl_new_std(&inst->ctrl_handler, &vdec_ctrl_ops, + V4L2_CID_MIN_BUFFERS_FOR_CAPTURE, 1, 32, 1, 1); + if (ctrl) + ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE; + ret = inst->ctrl_handler.error; if (ret) { v4l2_ctrl_handler_free(&inst->ctrl_handler); From patchwork Mon Jun 12 16:27:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 103655 Delivered-To: patch@linaro.org Received: by 10.182.29.35 with SMTP id g3csp76860obh; Mon, 12 Jun 2017 09:30:27 -0700 (PDT) X-Received: by 10.98.212.73 with SMTP id u9mr24962765pfl.101.1497285027527; Mon, 12 Jun 2017 09:30:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497285027; cv=none; d=google.com; s=arc-20160816; b=v5LdJN2E1nYg/MWrFOE4WneOCBlgttls31RJr5eFbuBBzWMifLg6PP09QvG2/eSIEl YIxaJSr26NjFPAPqNtUPYnmGDvsF8u6vMQUdTbSAsGhINkMWLSkJs2U5h+dfTmyOt8i0 9bRacK09kNmdyqfnG+yzrKjcPA6HgeBc6AWpGxQfFbZO1dnNmvRi81yT0VCWvv48XdEF dUIu/aqLTdxKqpXan+M+sFdu2PYSDTOrF3qBc1hdoBMQF/mViYB5qAnpqxNHjO9hAZUL R92i/LyeERwGDFLWWFCJuXnGAIdbhwUAqF4jlxj8RfpdiDA5YvE/LGw35OUPvU0u3QLa a/Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=aDuHAavWjzJK/AlqSGd5cag/0XImK427/2z6vM4fArs=; b=0Rqy2MpJCVHBw6+d0zh4uTPugu22vYFlL7h1y2DrIl6eC1+qukXf7KMHy3iY9l3mF/ 2e5Uc4z9ENrIJQgOQ+7GYZDJloAgCRudPiKtih52269Pwrm55dcRTbAILD6auy8bffrG rJIXfzQ7AmUY9uyS+CbLge/JxaXdgnrQhMhHFKsi2FozOztIwzm6BXvY3VqlfCs18PoE 64iaVuEJY8YYTQpkht2BwEAGnOBFTwTlz4U0H8m4qFmw6u/L6CTShsaIbboiOpyPR6Z1 iqLUkudZPo4aBqyX6fkGbB0QhYLHLx/DD31qXp8hfN5dhzuwKohh25z8fIFlVMkrpVnS cd+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b34si7320935pld.201.2017.06.12.09.30.27; Mon, 12 Jun 2017 09:30:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932136AbdFLQaS (ORCPT + 25 others); Mon, 12 Jun 2017 12:30:18 -0400 Received: from mail-wr0-f174.google.com ([209.85.128.174]:35986 "EHLO mail-wr0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754880AbdFLQaP (ORCPT ); Mon, 12 Jun 2017 12:30:15 -0400 Received: by mail-wr0-f174.google.com with SMTP id v111so103607913wrc.3 for ; Mon, 12 Jun 2017 09:30:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aDuHAavWjzJK/AlqSGd5cag/0XImK427/2z6vM4fArs=; b=SP0r4nHPgqUCRmhcqqfW9X33QQr2MA6CYv42ENpOQGTz/BxRASVrE1JbXQOBaJ9Pp4 mR0O5DH5uaqmsFV54OtooCcn4VBq5FquAOADyOyNATNFZw1YFtQsE8YtJ8CK5hi73Fpd UcnS6yMqc9fdQNATfwwFNNrMno98d4Y6z3T84= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=aDuHAavWjzJK/AlqSGd5cag/0XImK427/2z6vM4fArs=; b=CNLe2k3i+Z/uhimwGIdDkSp4p9d2o25yGIoU5cZhdhxb8GTMZ1q6cYDexC0gtBWAWr mCjnKqxNI6YvvQ2AcwJA7Rb3t2a5Hotr5pkSziCqfuiq66Jw+E+1slCaPV/00Hzdk/xT NkOSTqLfwYH4s1T/4FBpNcfimYRFu6F3mvkE4lP2nnWOV+4uROx6H80WmhFIaT2FlD9c X2Vu9Qg7M+bVY9SqZHQff+U6ehOQZ7/jVJOOQ52ue5pQfTHcDcaYHMKTnwT1T5KttWbB q1tO0hc9AX13r+j1Z468qzU1kJWrWYdrG0ufkyiJ593k2oaAygvZ4QztJAZ/9p3NCbYk pLmA== X-Gm-Message-State: AKS2vOwZASPBrHSDo7+JgafQpyFkOWP2ipP1hRwLwwlSyl3MN88nybLC 1vQQ8hJsjMTjYlQf X-Received: by 10.28.28.134 with SMTP id c128mr8490259wmc.112.1497285003867; Mon, 12 Jun 2017 09:30:03 -0700 (PDT) Received: from mms-0440.qualcomm.mm-sol.com ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id 49sm14493531wrz.8.2017.06.12.09.30.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 12 Jun 2017 09:30:03 -0700 (PDT) From: Stanimir Varbanov To: Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Stanimir Varbanov , Mauro Carvalho Chehab Subject: [PATCH v10 18/18] media: venus: enable building with COMPILE_TEST Date: Mon, 12 Jun 2017 19:27:55 +0300 Message-Id: <1497284875-19999-19-git-send-email-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497284875-19999-1-git-send-email-stanimir.varbanov@linaro.org> References: <1497284875-19999-1-git-send-email-stanimir.varbanov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We want all media drivers to build with COMPILE_TEST, as the Coverity instance we use on Kernel works only for x86. Also, our test workflow relies on it, in order to identify git bisect breakages. Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Stanimir Varbanov --- drivers/media/platform/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig index 017e42ce0ff9..0898f63fa451 100644 --- a/drivers/media/platform/Kconfig +++ b/drivers/media/platform/Kconfig @@ -467,7 +467,7 @@ config VIDEO_TI_VPE_DEBUG config VIDEO_QCOM_VENUS tristate "Qualcomm Venus V4L2 encoder/decoder driver" depends on VIDEO_DEV && VIDEO_V4L2 && HAS_DMA - depends on ARCH_QCOM && IOMMU_DMA + depends on (ARCH_QCOM && IOMMU_DMA) || COMPILE_TEST select QCOM_MDT_LOADER select VIDEOBUF2_DMA_SG select V4L2_MEM2MEM_DEV