blob: 3eed98ed02f2a1eccb538589868a13217fbf84b3 [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
19 * @SOC_MBUS_PACKING_NONE: no packing, bit-for-bit transfer to RAM
20 * @SOC_MBUS_PACKING_2X8_PADHI: 16 bits transferred in 2 8-bit samples, in the
21 * possibly incomplete byte high bits are padding
22 * @SOC_MBUS_PACKING_2X8_PADLO: as above, but low bits are padding
23 * @SOC_MBUS_PACKING_EXTEND16: sample width (e.g., 10 bits) has to be extended
24 * to 16 bits
25 */
26enum soc_mbus_packing {
27 SOC_MBUS_PACKING_NONE,
28 SOC_MBUS_PACKING_2X8_PADHI,
29 SOC_MBUS_PACKING_2X8_PADLO,
30 SOC_MBUS_PACKING_EXTEND16,
Kassey Li64149de2011-05-20 04:08:39 -030031 SOC_MBUS_PACKING_VARIABLE,
Guennadi Liakhovetski9a742512009-12-11 11:41:28 -030032};
33
34/**
35 * enum soc_mbus_order - sample order on the media bus
36 * @SOC_MBUS_ORDER_LE: least significant sample first
37 * @SOC_MBUS_ORDER_BE: most significant sample first
38 */
39enum soc_mbus_order {
40 SOC_MBUS_ORDER_LE,
41 SOC_MBUS_ORDER_BE,
42};
43
44/**
45 * struct soc_mbus_pixelfmt - Data format on the media bus
46 * @name: Name of the format
47 * @fourcc: Fourcc code, that will be obtained if the data is
48 * stored in memory in the following way:
49 * @packing: Type of sample-packing, that has to be used
50 * @order: Sample order when storing in memory
51 * @bits_per_sample: How many bits the bridge has to sample
52 */
53struct soc_mbus_pixelfmt {
54 const char *name;
55 u32 fourcc;
56 enum soc_mbus_packing packing;
57 enum soc_mbus_order order;
58 u8 bits_per_sample;
59};
60
Guennadi Liakhovetski93f116d2011-05-13 13:21:36 -030061/**
62 * struct soc_mbus_lookup - Lookup FOURCC IDs by mediabus codes for pass-through
63 * @code: mediabus pixel-code
64 * @fmt: pixel format description
65 */
66struct soc_mbus_lookup {
67 enum v4l2_mbus_pixelcode code;
68 struct soc_mbus_pixelfmt fmt;
69};
70
71const struct soc_mbus_pixelfmt *soc_mbus_find_fmtdesc(
72 enum v4l2_mbus_pixelcode code,
73 const struct soc_mbus_lookup *lookup,
74 int n);
Guennadi Liakhovetski9a742512009-12-11 11:41:28 -030075const struct soc_mbus_pixelfmt *soc_mbus_get_fmtdesc(
76 enum v4l2_mbus_pixelcode code);
77s32 soc_mbus_bytes_per_line(u32 width, const struct soc_mbus_pixelfmt *mf);
Alberto Panizzo48a3c772011-01-12 08:16:19 -030078int soc_mbus_samples_per_pixel(const struct soc_mbus_pixelfmt *mf);
Guennadi Liakhovetski9a742512009-12-11 11:41:28 -030079
80#endif