From patchwork Wed May 14 06:13:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arun Kumar K X-Patchwork-Id: 23899 X-Patchwork-Delegate: kamil@wypas.org Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1WkSRu-0000i4-FT; Wed, 14 May 2014 08:13:54 +0200 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.72/mailfrontend-7) with esmtp id 1WkSRq-0002wI-10; Wed, 14 May 2014 08:13:52 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752986AbaENGNq (ORCPT + 1 other); Wed, 14 May 2014 02:13:46 -0400 Received: from mail-pa0-f41.google.com ([209.85.220.41]:58904 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751460AbaENGNq (ORCPT ); Wed, 14 May 2014 02:13:46 -0400 Received: by mail-pa0-f41.google.com with SMTP id lj1so1270313pab.0 for ; Tue, 13 May 2014 23:13:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=jWfPb6v0elAPRf2fQtUFTy4XMKfr6leG+EiLu/mF2RM=; b=mwsPDvDnf3FVgrI6wjwnSrUTRAAjPLeCnjZH0L/T/5N1efwYHFyVNvGnYW37ZuNrho dnkj/HzxfygFMuxUJ/tFTsX5QoLqQVRSMFlWUq00mtsdlkLUT75lhS9X8TGHOq4jm2Ql oyY2SUTuq3n/Syh/+3xLZzYz0IfBnh3AlyN/4qy0SxF5jGMl4rUpNAdiujMSWvWh9reW 5RFNrQLNHI+VwGXMnw0BFA9yMs8lC/48YlD1JE3TLIkUK1kApOxzZKm232vLEtU8RfL9 I2VxD+7iS07/l0qwkxkHvZ5B7k/f4aARa4ZkQowR9Cziwgxrs1p3MqAwIfLvZK5xqb4x gPBw== X-Received: by 10.66.253.33 with SMTP id zx1mr2022420pac.28.1400048025373; Tue, 13 May 2014 23:13:45 -0700 (PDT) Received: from localhost.localdomain ([14.140.216.146]) by mx.google.com with ESMTPSA id hb10sm1427795pbd.75.2014.05.13.23.13.40 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 13 May 2014 23:13:42 -0700 (PDT) From: Arun Kumar K To: linux-media@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: k.debski@samsung.com, s.nawrocki@samsung.com, avnd.kiran@samsung.com, arunkk.samsung@gmail.com Subject: [PATCH v3] [media] s5p-mfc: add init buffer cmd to MFCV6 Date: Wed, 14 May 2014 11:43:35 +0530 Message-Id: <1400048015-485-1-git-send-email-arun.kk@samsung.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2014.5.14.60318 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODY_SIZE_5000_5999 0, BODY_SIZE_7000_LESS 0, DKIM_SIGNATURE 0, FROM_NAME_PHRASE 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_URI_IN_BODY 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __MIME_TEXT_ONLY 0, __MULTIPLE_RCPTS_CC_X2 0, __SANE_MSGID 0, __STOCK_PHRASE_7 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS , __YOUTUBE_RCVD 0' From: avnd kiran Latest MFC v6 firmware requires tile mode and loop filter setting to be done as part of Init buffer command, in sync with v7. Since there are two versions of v6 firmware with different interfaces, it is differenciated using the version number read back from firmware which is a hexadecimal value based on the firmware date. Signed-off-by: avnd kiran Signed-off-by: Arun Kumar K --- Changes from v2 - Addressed Kamil's comment https://patchwork.linuxtv.org/patch/22989/ Changes from v1 - Check for v6 firmware date for differenciating old and new firmware as per comments from Kamil and Sylwester. --- drivers/media/platform/s5p-mfc/regs-mfc-v6.h | 1 + drivers/media/platform/s5p-mfc/regs-mfc-v7.h | 2 -- drivers/media/platform/s5p-mfc/s5p_mfc_common.h | 2 ++ drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c | 8 ++++---- drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c | 21 ++++++++++++++++++--- 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v6.h b/drivers/media/platform/s5p-mfc/regs-mfc-v6.h index 8d0b686..b47567c 100644 --- a/drivers/media/platform/s5p-mfc/regs-mfc-v6.h +++ b/drivers/media/platform/s5p-mfc/regs-mfc-v6.h @@ -132,6 +132,7 @@ #define S5P_FIMV_D_METADATA_BUFFER_ADDR_V6 0xf448 #define S5P_FIMV_D_METADATA_BUFFER_SIZE_V6 0xf44c #define S5P_FIMV_D_NUM_MV_V6 0xf478 +#define S5P_FIMV_D_INIT_BUFFER_OPTIONS_V6 0xf47c #define S5P_FIMV_D_CPB_BUFFER_ADDR_V6 0xf4b0 #define S5P_FIMV_D_CPB_BUFFER_SIZE_V6 0xf4b4 diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v7.h b/drivers/media/platform/s5p-mfc/regs-mfc-v7.h index ea5ec2a..82c96fa 100644 --- a/drivers/media/platform/s5p-mfc/regs-mfc-v7.h +++ b/drivers/media/platform/s5p-mfc/regs-mfc-v7.h @@ -18,8 +18,6 @@ #define S5P_FIMV_CODEC_VP8_ENC_V7 25 /* Additional registers for v7 */ -#define S5P_FIMV_D_INIT_BUFFER_OPTIONS_V7 0xf47c - #define S5P_FIMV_E_SOURCE_FIRST_ADDR_V7 0xf9e0 #define S5P_FIMV_E_SOURCE_SECOND_ADDR_V7 0xf9e4 #define S5P_FIMV_E_SOURCE_THIRD_ADDR_V7 0xf9e8 diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h index 4d17df9..f5404a6 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h @@ -287,6 +287,7 @@ struct s5p_mfc_priv_buf { * @warn_start: hardware error code from which warnings start * @mfc_ops: ops structure holding HW operation function pointers * @mfc_cmds: cmd structure holding HW commands function pointers + * @ver: firmware sub version * */ struct s5p_mfc_dev { @@ -330,6 +331,7 @@ struct s5p_mfc_dev { int warn_start; struct s5p_mfc_hw_ops *mfc_ops; struct s5p_mfc_hw_cmds *mfc_cmds; + int ver; }; /** diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c index ee05f2d..b86744f 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c @@ -238,7 +238,6 @@ static inline void s5p_mfc_clear_cmds(struct s5p_mfc_dev *dev) /* Initialize hardware */ int s5p_mfc_init_hw(struct s5p_mfc_dev *dev) { - unsigned int ver; int ret; mfc_debug_enter(); @@ -300,12 +299,13 @@ int s5p_mfc_init_hw(struct s5p_mfc_dev *dev) return -EIO; } if (IS_MFCV6_PLUS(dev)) - ver = mfc_read(dev, S5P_FIMV_FW_VERSION_V6); + dev->ver = mfc_read(dev, S5P_FIMV_FW_VERSION_V6); else - ver = mfc_read(dev, S5P_FIMV_FW_VERSION); + dev->ver = mfc_read(dev, S5P_FIMV_FW_VERSION); mfc_debug(2, "MFC F/W version : %02xyy, %02xmm, %02xdd\n", - (ver >> 16) & 0xFF, (ver >> 8) & 0xFF, ver & 0xFF); + (dev->ver >> 16) & 0xFF, (dev->ver >> 8) & 0xFF, + dev->ver & 0xFF); s5p_mfc_clock_off(); mfc_debug_leave(); return 0; diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c index 90edb19..444f0e8 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c @@ -48,6 +48,9 @@ #define OFFSETA(x) (((x) - dev->port_a) >> S5P_FIMV_MEM_OFFSET) #define OFFSETB(x) (((x) - dev->port_b) >> S5P_FIMV_MEM_OFFSET) +/* v2 interface version date of MFCv6 firmware */ +#define MFC_V6_FIRMWARE_INTERFACE_V2 0x120629 + /* Allocate temporary buffers for decoding */ static int s5p_mfc_alloc_dec_temp_buffers_v6(struct s5p_mfc_ctx *ctx) { @@ -1269,6 +1272,18 @@ static int s5p_mfc_set_enc_params_vp8(struct s5p_mfc_ctx *ctx) return 0; } +/* Check if newer v6 firmware with changed init buffer interface */ +static bool s5p_mfc_is_v6_fw_v2(struct s5p_mfc_dev *dev) +{ + if (IS_MFCV7(dev)) + return false; + /* + * FW date is in BCD format xx120629. So checking for + * LSB 24 bits is greater than new interface date. + */ + return (dev->ver & 0xffffff) >= MFC_V6_FIRMWARE_INTERFACE_V2; +} + /* Initialize decoding */ static int s5p_mfc_init_decode_v6(struct s5p_mfc_ctx *ctx) { @@ -1296,7 +1311,7 @@ static int s5p_mfc_init_decode_v6(struct s5p_mfc_ctx *ctx) WRITEL(ctx->display_delay, S5P_FIMV_D_DISPLAY_DELAY_V6); } - if (IS_MFCV7(dev)) { + if (IS_MFCV7(dev) || s5p_mfc_is_v6_fw_v2(dev)) { WRITEL(reg, S5P_FIMV_D_DEC_OPTIONS_V6); reg = 0; } @@ -1311,8 +1326,8 @@ static int s5p_mfc_init_decode_v6(struct s5p_mfc_ctx *ctx) if (ctx->dst_fmt->fourcc == V4L2_PIX_FMT_NV12MT_16X16) reg |= (0x1 << S5P_FIMV_D_OPT_TILE_MODE_SHIFT_V6); - if (IS_MFCV7(dev)) - WRITEL(reg, S5P_FIMV_D_INIT_BUFFER_OPTIONS_V7); + if (IS_MFCV7(dev) || s5p_mfc_is_v6_fw_v2(dev)) + WRITEL(reg, S5P_FIMV_D_INIT_BUFFER_OPTIONS_V6); else WRITEL(reg, S5P_FIMV_D_DEC_OPTIONS_V6);