From patchwork Wed May 21 09:29:30 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: 23996 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 1Wn2qZ-0002js-BF; Wed, 21 May 2014 11:30:03 +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-5) with esmtp id 1Wn2qX-0005e0-7D; Wed, 21 May 2014 11:30:03 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752141AbaEUJ3w (ORCPT + 1 other); Wed, 21 May 2014 05:29:52 -0400 Received: from mail-pa0-f47.google.com ([209.85.220.47]:57280 "EHLO mail-pa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751786AbaEUJ3u (ORCPT ); Wed, 21 May 2014 05:29:50 -0400 Received: by mail-pa0-f47.google.com with SMTP id lf10so1241094pab.20 for ; Wed, 21 May 2014 02:29:49 -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:in-reply-to:references; bh=zIgme6nnfUDEwahlzjj0oKMsQsvRNmtmMLT88ja3Epo=; b=TUeVgaQMlyTqB358zh6lrTYBdXE8DDR8xs3GML09hm8o7YKjMS3Ks99wfwARUA6XLB BoEdl8K4D42jpq585UlPJ8OhKG7h2OvgBlGYoP3nGlItBqWA9N7ZrFMFq98rL0wATYgE a04R8VB5Gc7VdXxCAWKSH2lojackarzgUetmu/4OF8PN2XJDix9teLMddcS0rjKx1eir L3/NU+ayJ7IAGgFwAXru2DemQmr8HdxNf2c4NOcVitZuHjJBYajKiBpaWwKI6qgOh2Ef IYxAUEMiynvdCre0KlS81QkWycp+7HITNHENw/dRZx+CbPYUhbychINfXzrRYfbZhA2y 8Nnw== X-Received: by 10.67.4.195 with SMTP id cg3mr56971173pad.21.1400664589784; Wed, 21 May 2014 02:29:49 -0700 (PDT) Received: from localhost.localdomain ([14.140.216.146]) by mx.google.com with ESMTPSA id fu12sm102504908pad.42.2014.05.21.02.29.45 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 21 May 2014 02:29:47 -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, posciak@chromium.org, avnd.kiran@samsung.com, sachin.kamat@linaro.org, t.figa@samsung.com, arunkk.samsung@gmail.com Subject: [PATCH v2 2/3] [media] s5p-mfc: Support multiple firmware sub-versions Date: Wed, 21 May 2014 14:59:30 +0530 Message-Id: <1400664571-13746-3-git-send-email-arun.kk@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1400664571-13746-1-git-send-email-arun.kk@samsung.com> References: <1400664571-13746-1-git-send-email-arun.kk@samsung.com> 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.21.91819 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, __IN_REP_TO 0, __MIME_TEXT_ONLY 0, __MULTIPLE_RCPTS_CC_X2 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS , __YOUTUBE_RCVD 0' For MFC firmwares, improved versions with bug fixes and feature additions are released keeping the firmware version including major and minor number same. The issue came with the release of a new MFCv6 firmware with an interface change. This patch adds the support of accepting multiple firmware binaries for every version with the driver trying to load firmwares starting from latest. This ensures full backward compatibility regardless of which firmware version and kernel version is used. Signed-off-by: Arun Kumar K Reviewed-by: Tomasz Figa --- drivers/media/platform/s5p-mfc/s5p_mfc.c | 13 +++++++++---- drivers/media/platform/s5p-mfc/s5p_mfc_common.h | 11 ++++++++++- drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c | 15 ++++++++++++--- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c index 8da4c23..7092b84 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c @@ -1343,7 +1343,7 @@ static struct s5p_mfc_variant mfc_drvdata_v5 = { .port_num = MFC_NUM_PORTS, .buf_size = &buf_size_v5, .buf_align = &mfc_buf_align_v5, - .fw_name = "s5p-mfc.fw", + .fw_name[0] = "s5p-mfc.fw", }; struct s5p_mfc_buf_size_v6 mfc_buf_size_v6 = { @@ -1370,7 +1370,12 @@ static struct s5p_mfc_variant mfc_drvdata_v6 = { .port_num = MFC_NUM_PORTS_V6, .buf_size = &buf_size_v6, .buf_align = &mfc_buf_align_v6, - .fw_name = "s5p-mfc-v6.fw", + .fw_name[0] = "s5p-mfc-v6.fw", + /* + * v6-v2 firmware contains bug fixes and interface change + * for init buffer command + */ + .fw_name[1] = "s5p-mfc-v6-v2.fw", }; struct s5p_mfc_buf_size_v6 mfc_buf_size_v7 = { @@ -1397,7 +1402,7 @@ static struct s5p_mfc_variant mfc_drvdata_v7 = { .port_num = MFC_NUM_PORTS_V7, .buf_size = &buf_size_v7, .buf_align = &mfc_buf_align_v7, - .fw_name = "s5p-mfc-v7.fw", + .fw_name[0] = "s5p-mfc-v7.fw", }; struct s5p_mfc_buf_size_v6 mfc_buf_size_v8 = { @@ -1424,7 +1429,7 @@ static struct s5p_mfc_variant mfc_drvdata_v8 = { .port_num = MFC_NUM_PORTS_V8, .buf_size = &buf_size_v8, .buf_align = &mfc_buf_align_v8, - .fw_name = "s5p-mfc-v8.fw", + .fw_name[0] = "s5p-mfc-v8.fw", }; static struct platform_device_id mfc_driver_ids[] = { diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h index 89681c3..de60185 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h @@ -38,6 +38,8 @@ #define MFC_BANK2_ALIGN_ORDER 13 #define MFC_BASE_ALIGN_ORDER 17 +#define MFC_FW_MAX_VERSIONS 2 + #include static inline dma_addr_t s5p_mfc_mem_cookie(void *a, void *b) @@ -163,6 +165,11 @@ enum s5p_mfc_decode_arg { MFC_DEC_RES_CHANGE, }; +enum s5p_mfc_fw_ver { + MFC_FW_V1, + MFC_FW_V2, +}; + #define MFC_BUF_FLAG_USED (1 << 0) #define MFC_BUF_FLAG_EOS (1 << 1) @@ -225,7 +232,7 @@ struct s5p_mfc_variant { u32 version_bit; struct s5p_mfc_buf_size *buf_size; struct s5p_mfc_buf_align *buf_align; - char *fw_name; + char *fw_name[MFC_FW_MAX_VERSIONS]; }; /** @@ -287,6 +294,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 + * @fw_ver: loaded firmware sub-version * */ struct s5p_mfc_dev { @@ -331,6 +339,7 @@ struct s5p_mfc_dev { struct s5p_mfc_hw_ops *mfc_ops; struct s5p_mfc_hw_cmds *mfc_cmds; const struct s5p_mfc_regs *mfc_regs; + enum s5p_mfc_fw_ver fw_ver; }; /** diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c index c97c7c8..452ad02 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c @@ -78,14 +78,23 @@ int s5p_mfc_alloc_firmware(struct s5p_mfc_dev *dev) int s5p_mfc_load_firmware(struct s5p_mfc_dev *dev) { struct firmware *fw_blob; - int err; + int i, err = -EINVAL; /* Firmare has to be present as a separate file or compiled * into kernel. */ mfc_debug_enter(); - err = request_firmware((const struct firmware **)&fw_blob, - dev->variant->fw_name, dev->v4l2_dev.dev); + for (i = MFC_FW_MAX_VERSIONS - 1; i >= 0; i--) { + if (!dev->variant->fw_name[i]) + continue; + err = request_firmware((const struct firmware **)&fw_blob, + dev->variant->fw_name[i], dev->v4l2_dev.dev); + if (!err) { + dev->fw_ver = (enum s5p_mfc_fw_ver) i; + break; + } + } + if (err != 0) { mfc_err("Firmware is not present in the /lib/firmware directory nor compiled in kernel\n"); return -EINVAL;