blob: 73f1e7eb60f3d15398e5cc28392b02b0731cd798 [file] [log] [blame]
Guennadi Liakhovetski9a742512009-12-11 11:41:28 -03001/*
2 * SoC-camera Media Bus API extensions
3 *
4 * Copyright (C) 2009, Guennadi Liakhovetski <g.liakhovetski@gmx.de>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef SOC_MEDIABUS_H
12#define SOC_MEDIABUS_H
13
14#include <linux/videodev2.h>
Laurent Pinchart2ef2d5a2010-03-15 19:33:31 -030015#include <linux/v4l2-mediabus.h>
Guennadi Liakhovetski9a742512009-12-11 11:41:28 -030016
17/**
18 * enum soc_mbus_packing - data packing types on the media-bus
Guennadi Liakhovetskicc552b62011-05-20 04:25:09 -030019 * @SOC_MBUS_PACKING_NONE: no packing, bit-for-bit transfer to RAM, one
20 * sample represents one pixel
Guennadi Liakhovetski9a742512009-12-11 11:41:28 -030021 * @SOC_MBUS_PACKING_2X8_PADHI: 16 bits transferred in 2 8-bit samples, in the
22 * possibly incomplete byte high bits are padding
23 * @SOC_MBUS_PACKING_2X8_PADLO: as above, but low bits are padding
24 * @SOC_MBUS_PACKING_EXTEND16: sample width (e.g., 10 bits) has to be extended
25 * to 16 bits
Guennadi Liakhovetskicc552b62011-05-20 04:25:09 -030026 * @SOC_MBUS_PACKING_VARIABLE: compressed formats with variable packing
27 * @SOC_MBUS_PACKING_1_5X8: used for packed YUV 4:2:0 formats, where 4
28 * pixels occupy 6 bytes in RAM
Guennadi Liakhovetski9a742512009-12-11 11:41:28 -030029 */
30enum soc_mbus_packing {
31 SOC_MBUS_PACKING_NONE,
32 SOC_MBUS_PACKING_2X8_PADHI,
33 SOC_MBUS_PACKING_2X8_PADLO,
34 SOC_MBUS_PACKING_EXTEND16,
Kassey Li64149de2011-05-20 04:08:39 -030035 SOC_MBUS_PACKING_VARIABLE,
Guennadi Liakhovetskicc552b62011-05-20 04:25:09 -030036 SOC_MBUS_PACKING_1_5X8,
Guennadi Liakhovetski9a742512009-12-11 11:41:28 -030037};
38
39/**
40 * enum soc_mbus_order - sample order on the media bus
41 * @SOC_MBUS_ORDER_LE: least significant sample first
42 * @SOC_MBUS_ORDER_BE: most significant sample first
43 */
44enum soc_mbus_order {
45 SOC_MBUS_ORDER_LE,
46 SOC_MBUS_ORDER_BE,
47};
48
49/**
50 * struct soc_mbus_pixelfmt - Data format on the media bus
51 * @name: Name of the format
52 * @fourcc: Fourcc code, that will be obtained if the data is
53 * stored in memory in the following way:
54 * @packing: Type of sample-packing, that has to be used
55 * @order: Sample order when storing in memory
56 * @bits_per_sample: How many bits the bridge has to sample
57 */
58struct soc_mbus_pixelfmt {
59 const char *name;
60 u32 fourcc;
61 enum soc_mbus_packing packing;
62 enum soc_mbus_order order;
63 u8 bits_per_sample;
64};
65
Guennadi Liakhovetski93f116d2011-05-13 13:21:36 -030066/**
67 * struct soc_mbus_lookup - Lookup FOURCC IDs by mediabus codes for pass-through
68 * @code: mediabus pixel-code
69 * @fmt: pixel format description
70 */
71struct soc_mbus_lookup {
72 enum v4l2_mbus_pixelcode code;
73 struct soc_mbus_pixelfmt fmt;
74};
75
76const struct soc_mbus_pixelfmt *soc_mbus_find_fmtdesc(
77 enum v4l2_mbus_pixelcode code,
78 const struct soc_mbus_lookup *lookup,
79 int n);
Guennadi Liakhovetski9a742512009-12-11 11:41:28 -030080const struct soc_mbus_pixelfmt *soc_mbus_get_fmtdesc(
81 enum v4l2_mbus_pixelcode code);
82s32 soc_mbus_bytes_per_line(u32 width, const struct soc_mbus_pixelfmt *mf);
Guennadi Liakhovetskicc552b62011-05-20 04:25:09 -030083int soc_mbus_samples_per_pixel(const struct soc_mbus_pixelfmt *mf,
84 unsigned int *numerator, unsigned int *denominator);
Guennadi Liakhovetski32c69fcc2011-07-26 11:38:01 -030085unsigned int soc_mbus_config_compatible(const struct v4l2_mbus_config *cfg,
86 unsigned int flags);
Guennadi Liakhovetski9a742512009-12-11 11:41:28 -030087
88#endif