Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3085812ybg; Thu, 24 Oct 2019 21:44:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqw4f/gVkzir/R/Tw1nJHVsJLx2tPmeFwZNiCAWrdx/KY0w0rXKxHy56NY+LYWiOHIFs4weA X-Received: by 2002:a50:b6cb:: with SMTP id f11mr1729232ede.299.1571978689721; Thu, 24 Oct 2019 21:44:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571978689; cv=none; d=google.com; s=arc-20160816; b=XA3f3dOnSSIixG1XyKOwexE+LcVYL3Yx9+SzxTxkrTCQE1QihsnLtCXV9QkoLxM82R dcRgDPNhISzlU4bB6NsF5vGrwcUPB5pTCXE/9QZWRn8aHWPh6i4QYO70ymiSEgijo9Gx j21MVLHxCcIN2nhUiKpKkmKXTrzva00z0z2QbKJYbWXA7XpkgKGqUDzRRuXw8nTsi1sN SEiYXDyhCA05cjpZ9f19TTVplyx0dW/A4icdOPB01kc7l/fBUkkT+wcY9PtFp07Q9lQv 5vRivSQ8E9BlYP7DFU9JsZLIe35Bnmohff9m2doO00zlIyfyAUG4jP1HZ8k/aC4rvwTH ObTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=2Fg4OORdS56GYlEdlxxKyHlR08HjtyPW5mXDJkHAU3c=; b=qcWdM7UDO+knfSKwiu9VR5GrphUMPou5WXCg43mKTq1U3gPe5sYP8bQW+84Rco+yfr PEc5+GNgE+dCyvjmaiS26TEe+dfZs37mBebv2Q2tHy5JocTIY6uZtj4GD7TM/UyJq6fy elexyS6aNy/4xwCjWE+dS0XlzOI24pexmL7o8Zu1S1Gg6ElyaMcIMlzuoQFq6SllV9BD 7CJrb8w8yvNFfvAKsAPeSIRitkWDgiq5YeGe6kFDCK5EzrzFVJ3GZjRPPk24KbqHN8kb sRkrop91R81Y6uBu8w3QbWRrrEveqIcqi2MDVMVv8jJBvRikpOvt+i+00nzjEt/+ybrd 8TIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=LErg4eJH; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j3si525147edj.448.2019.10.24.21.44.25; Thu, 24 Oct 2019 21:44:49 -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=@chromium.org header.s=google header.b=LErg4eJH; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2408858AbfJXJYB (ORCPT + 99 others); Thu, 24 Oct 2019 05:24:01 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:40131 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393061AbfJXJYB (ORCPT ); Thu, 24 Oct 2019 05:24:01 -0400 Received: by mail-ed1-f66.google.com with SMTP id p59so9673865edp.7 for ; Thu, 24 Oct 2019 02:23:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=2Fg4OORdS56GYlEdlxxKyHlR08HjtyPW5mXDJkHAU3c=; b=LErg4eJHixvsMHo3T4UdsdOcjyo5lbO9XudSeZq6rpgNnkVpGr/b0G90t4XOSP66/E yPiEP9VtvxDCkUlH7d1janZhA4XnWhbkjvm/cOE2ToCJXuDoxd+uba3V89MU7eceWGgo 3dPD97YPgwTyy5neIrYaAT8SNNB8krsO2ClP8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=2Fg4OORdS56GYlEdlxxKyHlR08HjtyPW5mXDJkHAU3c=; b=gr+QAlo5VzN4dduBfhFSSxLXOi03cTy/V06FvIm4vlHOzZFCQZgA10etsRAQu6aLx9 xXy6glPh7OzxBSDoz5OL5i8i+UdtatJHQdS5bgZp9+jmQ4tHdHIHXiF6BOGMvSlTCJqx uVAVJhK0q7rr9j1TrzYxGsHmqbb1eI89j7wFzp+J2nY61CEzFA9LYhXGCSv0JnywkOr4 ZtMJoxHsH3loq7Ng/vm2fF3RAge3t91ecFNKL9i2zWL6FTgKPlvLRl64U+6cpalaKLrF 5sWOxNCQ3gAK5CfKL2a3UhKhFzI46iVoLoGB7UpZEVjowKPZ52zEKcexNpZlZkh+3DQj PNPA== X-Gm-Message-State: APjAAAXzc99P+XkS9Ek/OOwi7cRKSaYgESL9AUIptgxXPNYQhvi7IsMb xB+c0s0tHl5N5Wecz7BZhscZ+6va86VygA== X-Received: by 2002:a17:906:7094:: with SMTP id b20mr37286315ejk.134.1571909038413; Thu, 24 Oct 2019 02:23:58 -0700 (PDT) Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com. [209.85.221.54]) by smtp.gmail.com with ESMTPSA id l49sm434653edb.3.2019.10.24.02.23.55 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 24 Oct 2019 02:23:56 -0700 (PDT) Received: by mail-wr1-f54.google.com with SMTP id t16so20076735wrr.1 for ; Thu, 24 Oct 2019 02:23:55 -0700 (PDT) X-Received: by 2002:a5d:6a42:: with SMTP id t2mr2809593wrw.155.1571909035112; Thu, 24 Oct 2019 02:23:55 -0700 (PDT) MIME-Version: 1.0 References: <20191017084033.28299-1-xia.jiang@mediatek.com> <20191017084033.28299-6-xia.jiang@mediatek.com> <20191023103945.GA41089@chromium.org> <1571906317.6254.64.camel@mhfsdcap03> In-Reply-To: <1571906317.6254.64.camel@mhfsdcap03> From: Tomasz Figa Date: Thu, 24 Oct 2019 18:23:43 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 5/5] media: platform: Add jpeg dec/enc feature To: Xia Jiang Cc: Hans Verkuil , Mauro Carvalho Chehab , Rob Herring , Matthias Brugger , Rick Chang , Linux Media Mailing List , linux-devicetree , Linux Kernel Mailing List , "list@263.net:IOMMU DRIVERS , Joerg Roedel ," , "moderated list:ARM/Mediatek SoC support" , Marek Szyprowski , srv_heupstream Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 24, 2019 at 5:38 PM Xia Jiang wrote: > > On Wed, 2019-10-23 at 19:39 +0900, Tomasz Figa wrote: > > Hi Xia, > > > > On Thu, Oct 17, 2019 at 04:40:38PM +0800, Xia Jiang wrote: > > > Add mtk jpeg encode v4l2 driver based on jpeg decode, because that jp= eg > > > decode and encode have great similarities with function operation. > > > > > > Signed-off-by: Xia Jiang > > > --- > > > v4: split mtk_jpeg_try_fmt_mplane() to two functions, one for encoder= , > > > one for decoder. > > > split mtk_jpeg_set_default_params() to two functions, one for > > > encoder, one for decoder. > > > add cropping support for encoder in g/s_selection ioctls. > > > change exif mode support by using V4L2_JPEG_ACTIVE_MARKER_APP1. > > > change MTK_JPEG_MAX_WIDTH/MTK_JPEG_MAX_HEIGH from 8192 to 65535 b= y > > > specification. > > > move width shifting operation behind aligning operation in > > > mtk_jpeg_try_enc_fmt_mplane() for bug fix. > > > fix user abuseing data_offset issue for DMABUF in > > > mtk_jpeg_set_enc_src(). > > > fix kbuild warings: change MTK_JPEG_MIN_HEIGHT/MTK_JPEG_MAX_HEIGH= T > > > and MTK_JPEG_MIN_WIDTH/MTK_JPEG_MAX_WIDTH fro= m > > > 'int' type to 'unsigned int' type. > > > fix msleadingly indented of 'else'. > > > > > > v3: delete Change-Id. > > > only test once handler->error after the last v4l2_ctrl_new_std(). > > > seperate changes of v4l2-ctrls.c and v4l2-controls.h to new patch= . > > > > > > v2: fix compliance test fail, check created buffer size in driver. > > > --- > > > drivers/media/platform/mtk-jpeg/Makefile | 5 +- > > > .../media/platform/mtk-jpeg/mtk_jpeg_core.c | 731 +++++++++++++++-= -- > > > .../media/platform/mtk-jpeg/mtk_jpeg_core.h | 123 ++- > > > .../media/platform/mtk-jpeg/mtk_jpeg_dec_hw.h | 7 +- > > > .../media/platform/mtk-jpeg/mtk_jpeg_enc_hw.c | 175 +++++ > > > .../media/platform/mtk-jpeg/mtk_jpeg_enc_hw.h | 60 ++ > > > .../platform/mtk-jpeg/mtk_jpeg_enc_reg.h | 49 ++ > > > 7 files changed, 1004 insertions(+), 146 deletions(-) > > > create mode 100644 drivers/media/platform/mtk-jpeg/mtk_jpeg_enc_hw.c > > > create mode 100644 drivers/media/platform/mtk-jpeg/mtk_jpeg_enc_hw.h > > > create mode 100644 drivers/media/platform/mtk-jpeg/mtk_jpeg_enc_reg.= h > > > > > > > First of all, thanks for the patch! > > > > Please check my comments below. > > > > My general feeling about this code is that the encoder hardware block i= s > > completely orthogonal from the decoder block and there is very little c= ode > > reuse from the original decoder driver. > > > > Moreover, a lot of existing code now needs if (decoder) { ... } else {.= .. } > > segments, which complicates the code. > > > > Would it perhaps make sense to instead create a separate mtk-jpeg-enc > > driver? > > > Dear Tomasz, > > Thanks for your comments. > > My reasons about the architecture of jpeg enc driver are as follows: > > The first internal design and realization of jpeg enc driver was a > separate driver, but found that mtk_jpeg_core.c and mtk_jpeg_enc_core.c > have lots of reuse.Because that the core.c mainly contains realization > of v4L2 ioctl functions and some logic which are high similarity between > encoder and decoder. > > The jpeg encoder and decoder are two independent hardwares exactly, so > the code about hardware specification(register setting) are > separated(mtk_jpeg_enc_hw.c and mtk_jpeg_dec_hw.c). > > As for 17 existing code segments contain if(decoder){} else {}, they are > not complicated IMHO.The complicated(multilayer nested) functions are > separated in V4 version as Hans recommendation. > > By the way,the upstreamed module s5p-jpeg > (https://elixir.bootlin.com/linux/latest/source/drivers/media/platform/s5= p-jpeg/jpeg-core.c#L1998) also use encoder and decoder mode in the common c= ore.c, but their encoder and decoder are the same hardware.Maybe our jpeg e= nc and dec are designed into one hardware in the future.In that case the cu= rrent architecture is more compatible. > > So I prefer the current design. > Would you be able to give some numbers to show the code reuse to justify using the same driver? From my observation, a new driver would result in a significantly cleaner code. If there is a further hardware architecture change, that would likely require another driver, because it wouldn't be compatible with existing programming model anyway. Regardless of that, if we end up with reusing the same driver, I'd like you to fix the issues existing in the current base before adding the encoder functionality. Best regards, Tomasz