Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3920782imm; Mon, 30 Jul 2018 05:55:37 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeT2bs3Di/k4QtbLEJMOnZmYAq1q3T90OLPT2muRk1ZP3m4gj5x7AcQrWv59yGSMwg0aF9b X-Received: by 2002:a17:902:4401:: with SMTP id k1-v6mr14323858pld.97.1532955337099; Mon, 30 Jul 2018 05:55:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532955337; cv=none; d=google.com; s=arc-20160816; b=zLSI/VINgeE4ttVc4acHDUJ7zDU8Rp8O+hmnEpWUgxY6cPXhjhioJJ+TkXi19gHU/+ MSClZGMSnvkAa0A0bbSKUG9BILadVgnOngmOyosCCYVcYq6lskX9cUvwFZpO1BCcqsaQ ywOl7WrOajk6IpYEgexjjP2zPnnXirFZYEaoDdsb7lf3OKpJyHvPVr68vkY98qL4JvSH fvmkhLH8JxpLWncDjfOMPRvN/6mwoPQ9kRUPFwHzwg3JLlmpPHZ14jHRwcBe5MnN5Twt x3gdmjaOTJaIdPv5qTgVjb5fjcTa6nIwXaZVaY0j37AjArrPeFOS4+sdE1IJfxPGnNNg r4KQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:organization:references :in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=BoxwZVBse42ZqUYsY9h7O+HpD1gjWlDi/pm/RHIPY7U=; b=EiIdakR7CQwSpQ3YCnkQ/lhIxcfDdBsVA8O9KGirCLvImuhLCbvP/eD2mJF5Cr9bGj 6cgmxS92FNLDIOQVR54LJXCnOny8t9EGfpWJX8BL8b9Jt2mZ/+/aMnUp3i3L7l2cLBw9 KupAN4t1psH2dNDt4fkc9DOXsvuS4wtm3R5h9OaKb8wvCWRIsqSTaKr0tdFsCs94Nacy P2ge9/GR/X0OHd57oFBFruDmBNsfAa80UTEkoKbxaISPDoRX3BQKqKto28N8iYb25mnv w5dVMTHiYFegMzZ3gLys+uwxis96QjM+d4vGaJGt924oNJPl09APUQQ6FZjky7K5D5mn Ycnw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g11-v6si4956943plb.323.2018.07.30.05.55.22; Mon, 30 Jul 2018 05:55:37 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732260AbeG3O27 (ORCPT + 99 others); Mon, 30 Jul 2018 10:28:59 -0400 Received: from mail.bootlin.com ([62.4.15.54]:59089 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730125AbeG3O26 (ORCPT ); Mon, 30 Jul 2018 10:28:58 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 33E75207AC; Mon, 30 Jul 2018 14:54:05 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from aptenodytes (AAubervilliers-681-1-89-120.w90-88.abo.wanadoo.fr [90.88.30.120]) by mail.bootlin.com (Postfix) with ESMTPSA id CB54620703; Mon, 30 Jul 2018 14:54:04 +0200 (CEST) Message-ID: Subject: Re: [PATCH 9/9] media: cedrus: Add H264 decoding support From: Paul Kocialkowski To: Maxime Ripard , hans.verkuil@cisco.com, acourbot@chromium.org, sakari.ailus@linux.intel.com, Laurent Pinchart Cc: tfiga@chromium.org, posciak@chromium.org, Chen-Yu Tsai , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org, nicolas.dufresne@collabora.com, jenskuske@gmail.com, linux-sunxi@googlegroups.com, Thomas Petazzoni Date: Mon, 30 Jul 2018 14:54:05 +0200 In-Reply-To: <20180613140714.1686-10-maxime.ripard@bootlin.com> References: <20180613140714.1686-1-maxime.ripard@bootlin.com> <20180613140714.1686-10-maxime.ripard@bootlin.com> Organization: Bootlin Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-qKX9WeEPvbhhbycnfLR7" X-Mailer: Evolution 3.28.4 Mime-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-qKX9WeEPvbhhbycnfLR7 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, On Wed, 2018-06-13 at 16:07 +0200, Maxime Ripard wrote: > Introduce some basic H264 decoding support in cedrus. So far, only the > baseline profile videos have been tested, and some more advanced features > used in higher profiles are not even implemented. While working on H265 support, I noticed a few things that should apply to H264 as well. [...] > +struct sunxi_cedrus_h264_sram_ref_pic { > + __le32 top_field_order_cnt; > + __le32 bottom_field_order_cnt; > + __le32 frame_info; > + __le32 luma_ptr; > + __le32 chroma_ptr; > + __le32 extra_data_ptr; > + __le32 extra_data_end; These two previous fields represent the top and bottom (field) motion vector column buffer addresses, so the second field is not the end of the first one. These fields should be frame-specific and they are called topmv_coladdr, botmv_coladdr by Allwinner. > + __le32 reserved; > +} __packed; > + [...] > +static void sunxi_cedrus_fill_ref_pic(struct sunxi_cedrus_h264_sram_ref_= pic *pic, > + struct vb2_buffer *buf, > + dma_addr_t extra_buf, > + size_t extra_buf_len, > + unsigned int top_field_order_cnt, > + unsigned int bottom_field_order_cnt, > + enum sunxi_cedrus_h264_pic_type pic_type) > +{ > + pic->top_field_order_cnt =3D top_field_order_cnt; > + pic->bottom_field_order_cnt =3D bottom_field_order_cnt; > + pic->frame_info =3D pic_type << 8; > + pic->luma_ptr =3D vb2_dma_contig_plane_dma_addr(buf, 0) - PHYS_OFFSET; > + pic->chroma_ptr =3D vb2_dma_contig_plane_dma_addr(buf, 1) - PHYS_OFFSET= ; > + pic->extra_data_ptr =3D extra_buf - PHYS_OFFSET; > + pic->extra_data_end =3D (extra_buf - PHYS_OFFSET) + extra_buf_len; > +} > + > +static void sunxi_cedrus_write_frame_list(struct sunxi_cedrus_ctx *ctx, > + struct sunxi_cedrus_run *run) > +{ > + struct sunxi_cedrus_h264_sram_ref_pic pic_list[SUNXI_CEDRUS_H264_FRAME_= NUM]; > + const struct v4l2_ctrl_h264_decode_param *dec_param =3D run->h264.decod= e_param; > + const struct v4l2_ctrl_h264_slice_param *slice =3D run->h264.slice_para= m; > + const struct v4l2_ctrl_h264_sps *sps =3D run->h264.sps; > + struct sunxi_cedrus_buffer *output_buf; > + struct sunxi_cedrus_dev *dev =3D ctx->dev; > + unsigned long used_dpbs =3D 0; > + unsigned int position; > + unsigned int output =3D 0; > + unsigned int i; > + > + memset(pic_list, 0, sizeof(pic_list)); > + > + for (i =3D 0; i < ARRAY_SIZE(dec_param->dpb); i++) { > + const struct v4l2_h264_dpb_entry *dpb =3D &dec_param->dpb[i]; > + const struct sunxi_cedrus_buffer *cedrus_buf; > + struct vb2_buffer *ref_buf; > + > + if (!(dpb->flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE)) > + continue; > + > + ref_buf =3D ctx->dst_bufs[dpb->buf_index]; > + cedrus_buf =3D vb2_to_cedrus_buffer(ref_buf); > + position =3D cedrus_buf->codec.h264.position; > + used_dpbs |=3D BIT(position); > + =09 > + sunxi_cedrus_fill_ref_pic(&pic_list[position], ref_buf, > + ctx->codec.h264.mv_col_buf_dma, > + ctx->codec.h264.mv_col_buf_size, Following up on my previous comment, this should be specific to each frame, with 2 buffer chunks per frame (top and bottom fields) as done in Allwinner's H264MallocBuffer function.=20 [...] > +static void sunxi_cedrus_set_params(struct sunxi_cedrus_ctx *ctx, > + struct sunxi_cedrus_run *run) > +{ > + const struct v4l2_ctrl_h264_slice_param *slice =3D run->h264.slice_para= m; > + const struct v4l2_ctrl_h264_pps *pps =3D run->h264.pps; > + const struct v4l2_ctrl_h264_sps *sps =3D run->h264.sps; > + struct sunxi_cedrus_dev *dev =3D ctx->dev; > + dma_addr_t src_buf_addr; > + u32 offset =3D slice->header_bit_size; > + u32 len =3D (slice->size * 8) - offset; > + u32 reg; > + > + sunxi_cedrus_write(dev, ctx->codec.h264.pic_info_buf_dma - PHYS_OFFSET,= 0x250); > + sunxi_cedrus_write(dev, (ctx->codec.h264.pic_info_buf_dma - PHYS_OFFSET= ) + 0x48000, 0x254); > + > + sunxi_cedrus_write(dev, len, VE_H264_VLD_LEN); > + sunxi_cedrus_write(dev, offset, VE_H264_VLD_OFFSET); > + > + src_buf_addr =3D vb2_dma_contig_plane_dma_addr(&run->src->vb2_buf, 0); > + src_buf_addr -=3D PHYS_OFFSET; > + sunxi_cedrus_write(dev, VE_H264_VLD_ADDR_VAL(src_buf_addr) | > + VE_H264_VLD_ADDR_FIRST | VE_H264_VLD_ADDR_VALID | VE_H264_VLD_ADDR= _LAST, > + VE_H264_VLD_ADDR); > + sunxi_cedrus_write(dev, src_buf_addr + VBV_SIZE - 1, VE_H264_VLD_END); > + > + sunxi_cedrus_write(dev, VE_H264_TRIGGER_TYPE_INIT_SWDEC, > + VE_H264_TRIGGER_TYPE); It seems that this trigger type is only useful when trying to subsequently access the bitstream data from the VPU (for easier parsing, as done in libvdpau-sunxi), but it should not be required when all the parsing was done already and no such access is necessary. I haven't tested without it so far, but I have a hunch we can spare this call. Cheers, Paul --=20 Paul Kocialkowski, Bootlin (formerly Free Electrons) Embedded Linux and kernel engineering https://bootlin.com --=-qKX9WeEPvbhhbycnfLR7 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEJZpWjZeIetVBefti3cLmz3+fv9EFAltfCm0ACgkQ3cLmz3+f v9Ffywf/RGeHXXe5Y7+Nd3BhBbU5tyVE87jhcUTuMPA6Hv5455gGaB4mYl8SgUDU U0RWpRnZv/hpTrFCTfMzQPZzrPqQNd0SKK4vHvis4/hmaQCLK4LC6hSHp/mBdHhi zHZB55cwA3PyC+CCWahXFbRqHE/7q9OVMM9bsYfpXcMx+6p1eBNP+YFdQmGrYU1L 9eDVhdQK3Nia42f5sx3k2vqyWaqk90K87hxI589AS/8oW6FYdNc9osspbDihTCzM 2WEdzd8U5bHY5qBYAhbZF0Ijf1pSfO+/VvVLFK4Jj6yrA4DJUkO3nn2pDZIUuY6o +wB/yqao497tYvyoLgtRtsnmPXal3A== =IEbq -----END PGP SIGNATURE----- --=-qKX9WeEPvbhhbycnfLR7--