Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp202994ybp; Thu, 3 Oct 2019 12:16:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqzXkpUF7hsbkhvQIOXcNOERy/OPaPY8AS8jZmG0sCcnouqv+lpwXDcKE35Msj8GjzjDMmWG X-Received: by 2002:a50:a7c4:: with SMTP id i62mr11039082edc.92.1570130175242; Thu, 03 Oct 2019 12:16:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570130175; cv=none; d=google.com; s=arc-20160816; b=SO4L1QCAF2Xu7LMWRaCY2+V0QIOblNE0k7SxkYKejBPjVICuQ5KbFyoKTbxyLtV+D1 NxONr83H6hz8+kGiG1OYpFOJZMHb40O9cF+QEgqiU7JMUJH8AbR2PDzF/E/U6C28INwM aHggQV8wYx4ch09kEK6qXwgGWpcQ/tXNXNV0Jw3JlafP9lHa62PflLLeFGD6SWvoZhTC s/rzdHwuH0SC9iulUlLRfEhtUgwW9eIFDpNAGfmykrQyOR3owQw3wBcNnfiIxQC/FXYe EA03BZnWjUEJsNEn3j8boFgQf33vBoMIHjiIBVjaUH5bzJEyKovIpC9QPcEWN36yV49P S7iA== 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:mime-version :message-id:date:subject:cc:to:from; bh=uuCKCZuN1YOkvovLHNSKejMs3di+EseDaiAzsLSMg6c=; b=kQzsrrZ75C/x7GaErlwzeDetw6Aexb2hmUc4GkYecp+/qcOUSNG/2nLJ+gKUtfaFbt PMbiNU1Zvl73y/PVeuhpxJuHSDKwET+E2YPcAG/eEaj/7zs1nDL5AJMCi5pcu6qk/Z9o gsD1PnKFWldBNO8IiXLE30mgXeHxNelPti+4Ko/hgqS0DsUidP7zBwF6HzvVaKXhIpCT +MbOy0efVGQFxNxd0MvlCT6toXiN3GoUpplCB9NfTk1XIRcPG5nW3QBoJKxo7WVIlIUa vEI9UKVLdmwGZGAUS+uBUO1dIjO4HJYIj0+Noqpq5tg34FvAx73PWsvGegRAnSfCgl29 0Mww== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e11si1752702ejb.48.2019.10.03.12.15.49; Thu, 03 Oct 2019 12:16:15 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732496AbfJCTI6 (ORCPT + 99 others); Thu, 3 Oct 2019 15:08:58 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:45062 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732289AbfJCTI6 (ORCPT ); Thu, 3 Oct 2019 15:08:58 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id 0B9C528C499 From: Ezequiel Garcia To: linux-media@vger.kernel.org Cc: kernel@collabora.com, Tomasz Figa , linux-rockchip@lists.infradead.org, Heiko Stuebner , Jonas Karlman , Philipp Zabel , Boris Brezillon , Chris Healy , linux-kernel@vger.kernel.org, Ezequiel Garcia Subject: [PATCH v2 0/4] Enable Hantro G1 post-processor Date: Thu, 3 Oct 2019 16:08:29 -0300 Message-Id: <20191003190833.29046-1-ezequiel@collabora.com> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi all, The Hantro G1 VPU post-processor block can be pipelined with the decoder hardware, allowing to perform operations such as color conversion, scaling, rotation, cropping, among others. When the post-processor is enabled, the decoder hardware gets its own set of NV12 buffers (the native decoder format), and the post-processor is the owner of the CAPTURE buffers. This allows the application get processed (scaled, converted, etc) buffers, completely transparently. This feature is implemented by exposing the post-processed pixel formats on ENUM_FMT. When the application sets a pixel format other than NV12, and if the post-processor is MC-linked, the driver will make use of it, transparently. On this v2, the media controller API is now required to "enable" (aka link, in topology jargon) the post-processor. Therefore, applications now have to explicitly request this feature. For instance, the post-processor is enabled using the media-ctl tool: media-ctl -l "'decoder':1 -> 'rockchip,rk3288-vpu-dec':0[0]" media-ctl -l "'postproc':1 -> 'rockchip,rk3288-vpu-dec':0[1]" v4l2-ctl -d 1 --list-formats ioctl: VIDIOC_ENUM_FMT Type: Video Capture Multiplanar [0]: 'NV12' (Y/CbCr 4:2:0) [1]: 'YUYV' (YUYV 4:2:2) Patches 1 and 2 are simply cleanups needed to easier integrate the post-processor. Patch 2 is a bit invasive, but it's a step forward towards merging the implementation for RK3399 and RK3288. Patch 3 re-works the media-topology, making the decoder a v4l2_subdevice, instead of a bare entity. This allows to introduce a more accurate of the decoder+post-processor complex. Patch 4 introduces the post-processing support. This is tested on RK3288 platforms with MPEG-2, VP8 and H264 streams, decoding to YUY2 surfaces. For now, this series is only adding support for NV12-to-YUY2 conversion. The design and implementation is quite different from v1: * The decoder->post-processor topology is now exposed explicitly and applications need to configure the pipeline. By default, the decoder is enabled and the post-processor is disabled. * RGB post-processing output has been dropped. We might add this in the future, but for now, it seems it would make the code more complex without a use-case in mind. RGB is much more memory-consuming so less attractive than YUV, and modern GPUs and display controllers support YUV. * The post-processor implementation still supports RK3288 only. However, a generic register infrastructure is introduced to make addition of other variants such as RK3399 really easy. Ezequiel Garcia (4): media: hantro: Cleanup format negotiation helpers media: hantro: mpeg2_dec: Re-use common register macros media: hantro: Rework media topology media: hantro: Support color conversion via post-processing drivers/staging/media/hantro/Makefile | 1 + drivers/staging/media/hantro/hantro.h | 105 +++++- drivers/staging/media/hantro/hantro_drv.c | 336 ++++++++++++++---- .../staging/media/hantro/hantro_g1_h264_dec.c | 2 +- .../media/hantro/hantro_g1_mpeg2_dec.c | 188 ++++------ drivers/staging/media/hantro/hantro_g1_regs.h | 109 ++++-- .../staging/media/hantro/hantro_g1_vp8_dec.c | 2 +- drivers/staging/media/hantro/hantro_h264.c | 6 +- drivers/staging/media/hantro/hantro_hw.h | 13 + .../staging/media/hantro/hantro_postproc.c | 141 ++++++++ drivers/staging/media/hantro/hantro_v4l2.c | 116 ++++-- drivers/staging/media/hantro/rk3288_vpu_hw.c | 10 + 12 files changed, 754 insertions(+), 275 deletions(-) create mode 100644 drivers/staging/media/hantro/hantro_postproc.c -- 2.22.0