From patchwork Wed Jan 12 11:16:19 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Panizzo X-Patchwork-Id: 473781 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p0CBGoiO021336 for ; Wed, 12 Jan 2011 11:16:51 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753642Ab1ALLQZ (ORCPT ); Wed, 12 Jan 2011 06:16:25 -0500 Received: from mail-ww0-f44.google.com ([74.125.82.44]:64513 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752136Ab1ALLQZ (ORCPT ); Wed, 12 Jan 2011 06:16:25 -0500 Received: by wwa36 with SMTP id 36so478611wwa.1 for ; Wed, 12 Jan 2011 03:16:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:subject:from:to:cc:in-reply-to:references :content-type:date:message-id:mime-version:x-mailer :content-transfer-encoding; bh=uy33VpKWT91SKkrFmPJnIcpaMhinVJFdqTpHti6rufY=; b=UeWu/G4o2UkId8NbFVrRN8cGnru7h0zJNRAceCrjdI9RHtpTSF2i8nDwIQ07F6V8FQ 3Km0JblVgSHKLzlSX7JYKqNvYcQNGIGHOyd0yCvHvQHkb1B745xz9TwINZGttKyZ/YZx gqza8jOxfluHzIylg+ICDjkicLqFSBuXKpBv0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:cc:in-reply-to:references:content-type:date :message-id:mime-version:x-mailer:content-transfer-encoding; b=pSF8EfreGig5twsgmRlw9rLmE1jCDFEaqqmWLgx0lXkZtafb7FyxNEnLaxRfW635ad LVp2KTH4hW+gEkQ67c0selLs0CI6Vucsk2Om4enqQtIodYibDf5bJ3EV3/NB72TLO9FC 1rrIs6/rfjUB7vJjdqjI7pQXvFGm54IspmoUg= Received: by 10.216.173.7 with SMTP id u7mr3980439wel.50.1294830983567; Wed, 12 Jan 2011 03:16:23 -0800 (PST) Received: from [192.168.1.12] (host-9473-86-114.popwifi.it [94.73.86.114]) by mx.google.com with ESMTPS id n1sm268318weq.7.2011.01.12.03.16.21 (version=SSLv3 cipher=RC4-MD5); Wed, 12 Jan 2011 03:16:22 -0800 (PST) Subject: [PATCH 1/2] soc_mediabus: export a useful method to obtain the number of samples that makes up a pixel format From: Alberto Panizzo To: Guennadi Liakhovetski Cc: HansVerkuil , linux-media@vger.kernel.org, linux-kernel In-Reply-To: <1294830836.2576.46.camel@realization> References: <1290964687.3016.5.camel@realization> <1290965045.3016.11.camel@realization> <1294076008.2493.85.camel@realization> <1294092449.2493.135.camel@realization> <1294830836.2576.46.camel@realization> Date: Wed, 12 Jan 2011 12:16:19 +0100 Message-ID: <1294830979.2576.48.camel@realization> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 12 Jan 2011 11:16:53 +0000 (UTC) diff --git a/drivers/media/video/soc_mediabus.c b/drivers/media/video/soc_mediabus.c index 9139121..5bba424 100644 --- a/drivers/media/video/soc_mediabus.c +++ b/drivers/media/video/soc_mediabus.c @@ -132,6 +132,20 @@ static const struct soc_mbus_pixelfmt mbus_fmt[] = { }, }; +s32 soc_mbus_samples_per_pixel(const struct soc_mbus_pixelfmt *mf) +{ + switch (mf->packing) { + case SOC_MBUS_PACKING_NONE: + case SOC_MBUS_PACKING_EXTEND16: + return 1; + case SOC_MBUS_PACKING_2X8_PADHI: + case SOC_MBUS_PACKING_2X8_PADLO: + return 2; + } + return -EINVAL; +} +EXPORT_SYMBOL(soc_mbus_samples_per_pixel); + s32 soc_mbus_bytes_per_line(u32 width, const struct soc_mbus_pixelfmt *mf) { switch (mf->packing) { diff --git a/include/media/soc_mediabus.h b/include/media/soc_mediabus.h index 037cd7b..f21cbd0 100644 --- a/include/media/soc_mediabus.h +++ b/include/media/soc_mediabus.h @@ -61,5 +61,6 @@ struct soc_mbus_pixelfmt { const struct soc_mbus_pixelfmt *soc_mbus_get_fmtdesc( enum v4l2_mbus_pixelcode code); s32 soc_mbus_bytes_per_line(u32 width, const struct soc_mbus_pixelfmt *mf); +s32 soc_mbus_samples_per_pixel(const struct soc_mbus_pixelfmt *mf); #endif