From patchwork Tue Nov 19 14:27:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 3202531 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AA703C045B for ; Tue, 19 Nov 2013 14:28:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0230420373 for ; Tue, 19 Nov 2013 14:28:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 45C9A20318 for ; Tue, 19 Nov 2013 14:28:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753035Ab3KSO2E (ORCPT ); Tue, 19 Nov 2013 09:28:04 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:55623 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753010Ab3KSO2C (ORCPT ); Tue, 19 Nov 2013 09:28:02 -0500 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MWI00H7TLIMVM60@mailout3.samsung.com> for linux-media@vger.kernel.org; Tue, 19 Nov 2013 23:28:01 +0900 (KST) X-AuditID: cbfee61b-b7fd56d000001fc6-7f-528b7571d120 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 04.56.08134.1757B825; Tue, 19 Nov 2013 23:28:01 +0900 (KST) Received: from AMDC2362.DIGITAL.local ([106.120.53.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MWI00IBKLHFEGB0@mmp1.samsung.com>; Tue, 19 Nov 2013 23:28:01 +0900 (KST) From: Jacek Anaszewski To: linux-media@vger.kernel.org Cc: kyungmin.park@samsung.com, s.nawrocki@samsung.com, sw0312.kim@samsung.com, Jacek Anaszewski Subject: [PATCH 11/16] s5p-jpeg: Retrieve "YCbCr subsampling" field from the jpeg header Date: Tue, 19 Nov 2013 15:27:03 +0100 Message-id: <1384871228-6648-12-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1384871228-6648-1-git-send-email-j.anaszewski@samsung.com> References: <1384871228-6648-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrFJMWRmVeSWpSXmKPExsVy+t9jAd3C0u4ggzPtEha9V58zWpxtesNu 0bNhK6vF4TftrBYzJr9kc2D16NuyitHj8ya5AKYoLpuU1JzMstQifbsEroxZ9yewFLwRq9jX epm9gXGnUBcjJ4eEgInEyXWtLBC2mMSFe+vZuhi5OIQEFjFKrPrzjB3CaWeSmH5lKzNIFZuA ocTPF6+ZQGwRAXmJJ7032EBsZoEaiSlbb7CD2MICURL/J/0Am8oioCrxZUU3WA2vgIfEoRc3 gXo5gLYpSMyZZAMS5gQKT1m4HaxVSMBd4vzGk+wTGHkXMDKsYhRNLUguKE5KzzXSK07MLS7N S9dLzs/dxAgOkWfSOxhXNVgcYhTgYFTi4Z3g3hUkxJpYVlyZe4hRgoNZSYS3Mb87SIg3JbGy KrUoP76oNCe1+BCjNAeLkjjvwVbrQCGB9MSS1OzU1ILUIpgsEwenVANjINfhEtOE1VwVnq/m JjMn1dizbJ3gz3bO59fv2A3difVhd6a4r17Gks/uva57t8T0ed6Jmi124tYng5/afNg74/GP 9oUsn/6tso9N6bz5QnXmKqb/N2qCXh/Q8Kua5Fp2g+FIalrbltimuB8Pfjzm8rrgdntjTUH6 x92zbQy/PeKUfSv39WefEktxRqKhFnNRcSIAqbYHLg0CAAA= Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Make s5p_jpeg_parse_hdr function capable of parsing "YCbCr subsampling" field of a jpeg file header. Store the parsed value in the context. The information about source JPEG subsampling is required to make validation of destination format possible, which must be conducted for exynos4x12 device as the decoding process will not succeed if the destination format is set to YUV with subsampling lower than the one of the source JPEG image. With this knowledge the driver can adjust the destination format appropriately. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 35 ++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 68a82cc..e09b03a 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -624,10 +624,11 @@ static void skip(struct s5p_jpeg_buffer *buf, long len) } static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data *result, - unsigned long buffer, unsigned long size) + unsigned long buffer, unsigned long size, + struct s5p_jpeg_ctx *ctx) { int c, components, notfound; - unsigned int height, width, word; + unsigned int height, width, word, subsampling = 0; long length; struct s5p_jpeg_buffer jpeg_buffer; @@ -666,7 +667,15 @@ static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data *result, break; notfound = 0; - skip(&jpeg_buffer, components * 3); + if (components == 1) { + subsampling = 0x33; + } else { + skip(&jpeg_buffer, 1); + subsampling = get_byte(&jpeg_buffer); + skip(&jpeg_buffer, 1); + } + + skip(&jpeg_buffer, components * 2); break; /* skip payload-less markers */ @@ -688,6 +697,24 @@ static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data *result, result->w = width; result->h = height; result->size = components; + + switch (subsampling) { + case 0x11: + ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_444; + break; + case 0x21: + ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_422; + break; + case 0x22: + ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_420; + break; + case 0x33: + ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY; + break; + default: + return false; + } + return !notfound; } @@ -1426,7 +1453,7 @@ static void s5p_jpeg_buf_queue(struct vb2_buffer *vb) ctx->hdr_parsed = s5p_jpeg_parse_hdr(&tmp, (unsigned long)vb2_plane_vaddr(vb, 0), min((unsigned long)ctx->out_q.size, - vb2_get_plane_payload(vb, 0))); + vb2_get_plane_payload(vb, 0)), ctx); if (!ctx->hdr_parsed) { vb2_buffer_done(vb, VB2_BUF_STATE_ERROR); return;