Guennadi Liakhovetski | 9a74251 | 2009-12-11 11:41:28 -0300 | [diff] [blame] | 1 | /* |
| 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 Pinchart | 2ef2d5a | 2010-03-15 19:33:31 -0300 | [diff] [blame] | 15 | #include <linux/v4l2-mediabus.h> |
Guennadi Liakhovetski | 9a74251 | 2009-12-11 11:41:28 -0300 | [diff] [blame] | 16 | |
| 17 | /** |
| 18 | * enum soc_mbus_packing - data packing types on the media-bus |
Guennadi Liakhovetski | cc552b6 | 2011-05-20 04:25:09 -0300 | [diff] [blame] | 19 | * @SOC_MBUS_PACKING_NONE: no packing, bit-for-bit transfer to RAM, one |
| 20 | * sample represents one pixel |
Guennadi Liakhovetski | 9a74251 | 2009-12-11 11:41:28 -0300 | [diff] [blame] | 21 | * @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 Liakhovetski | cc552b6 | 2011-05-20 04:25:09 -0300 | [diff] [blame] | 26 | * @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 Liakhovetski | 9a74251 | 2009-12-11 11:41:28 -0300 | [diff] [blame] | 29 | */ |
| 30 | enum 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 Li | 64149de | 2011-05-20 04:08:39 -0300 | [diff] [blame] | 35 | SOC_MBUS_PACKING_VARIABLE, |
Guennadi Liakhovetski | cc552b6 | 2011-05-20 04:25:09 -0300 | [diff] [blame] | 36 | SOC_MBUS_PACKING_1_5X8, |
Guennadi Liakhovetski | 9a74251 | 2009-12-11 11:41:28 -0300 | [diff] [blame] | 37 | }; |
| 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 | */ |
| 44 | enum 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 | */ |
| 58 | struct 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 Liakhovetski | 93f116d | 2011-05-13 13:21:36 -0300 | [diff] [blame] | 66 | /** |
| 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 | */ |
| 71 | struct soc_mbus_lookup { |
| 72 | enum v4l2_mbus_pixelcode code; |
| 73 | struct soc_mbus_pixelfmt fmt; |
| 74 | }; |
| 75 | |
| 76 | const 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 Liakhovetski | 9a74251 | 2009-12-11 11:41:28 -0300 | [diff] [blame] | 80 | const struct soc_mbus_pixelfmt *soc_mbus_get_fmtdesc( |
| 81 | enum v4l2_mbus_pixelcode code); |
| 82 | s32 soc_mbus_bytes_per_line(u32 width, const struct soc_mbus_pixelfmt *mf); |
Guennadi Liakhovetski | cc552b6 | 2011-05-20 04:25:09 -0300 | [diff] [blame] | 83 | int soc_mbus_samples_per_pixel(const struct soc_mbus_pixelfmt *mf, |
| 84 | unsigned int *numerator, unsigned int *denominator); |
Guennadi Liakhovetski | 9a74251 | 2009-12-11 11:41:28 -0300 | [diff] [blame] | 85 | |
| 86 | #endif |