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 |
Phil Edworthy | 7b88fc0 | 2013-03-18 08:47:59 -0300 | [diff] [blame] | 29 | * @SOC_MBUS_PACKING_EXTEND32: sample width (e.g., 24 bits) has to be extended |
| 30 | * to 32 bits |
Guennadi Liakhovetski | 9a74251 | 2009-12-11 11:41:28 -0300 | [diff] [blame] | 31 | */ |
| 32 | enum soc_mbus_packing { |
| 33 | SOC_MBUS_PACKING_NONE, |
| 34 | SOC_MBUS_PACKING_2X8_PADHI, |
| 35 | SOC_MBUS_PACKING_2X8_PADLO, |
| 36 | SOC_MBUS_PACKING_EXTEND16, |
Kassey Li | 64149de | 2011-05-20 04:08:39 -0300 | [diff] [blame] | 37 | SOC_MBUS_PACKING_VARIABLE, |
Guennadi Liakhovetski | cc552b6 | 2011-05-20 04:25:09 -0300 | [diff] [blame] | 38 | SOC_MBUS_PACKING_1_5X8, |
Phil Edworthy | 7b88fc0 | 2013-03-18 08:47:59 -0300 | [diff] [blame] | 39 | SOC_MBUS_PACKING_EXTEND32, |
Guennadi Liakhovetski | 9a74251 | 2009-12-11 11:41:28 -0300 | [diff] [blame] | 40 | }; |
| 41 | |
| 42 | /** |
| 43 | * enum soc_mbus_order - sample order on the media bus |
| 44 | * @SOC_MBUS_ORDER_LE: least significant sample first |
| 45 | * @SOC_MBUS_ORDER_BE: most significant sample first |
| 46 | */ |
| 47 | enum soc_mbus_order { |
| 48 | SOC_MBUS_ORDER_LE, |
| 49 | SOC_MBUS_ORDER_BE, |
| 50 | }; |
| 51 | |
| 52 | /** |
Laurent Pinchart | ad3b81f | 2012-03-21 08:03:23 -0300 | [diff] [blame] | 53 | * enum soc_mbus_layout - planes layout in memory |
| 54 | * @SOC_MBUS_LAYOUT_PACKED: color components packed |
| 55 | * @SOC_MBUS_LAYOUT_PLANAR_2Y_U_V: YUV components stored in 3 planes (4:2:2) |
| 56 | * @SOC_MBUS_LAYOUT_PLANAR_2Y_C: YUV components stored in a luma and a |
| 57 | * chroma plane (C plane is half the size |
| 58 | * of Y plane) |
| 59 | * @SOC_MBUS_LAYOUT_PLANAR_Y_C: YUV components stored in a luma and a |
| 60 | * chroma plane (C plane is the same size |
| 61 | * as Y plane) |
| 62 | */ |
| 63 | enum soc_mbus_layout { |
| 64 | SOC_MBUS_LAYOUT_PACKED = 0, |
| 65 | SOC_MBUS_LAYOUT_PLANAR_2Y_U_V, |
| 66 | SOC_MBUS_LAYOUT_PLANAR_2Y_C, |
| 67 | SOC_MBUS_LAYOUT_PLANAR_Y_C, |
| 68 | }; |
| 69 | |
| 70 | /** |
Guennadi Liakhovetski | 9a74251 | 2009-12-11 11:41:28 -0300 | [diff] [blame] | 71 | * struct soc_mbus_pixelfmt - Data format on the media bus |
| 72 | * @name: Name of the format |
| 73 | * @fourcc: Fourcc code, that will be obtained if the data is |
| 74 | * stored in memory in the following way: |
| 75 | * @packing: Type of sample-packing, that has to be used |
| 76 | * @order: Sample order when storing in memory |
| 77 | * @bits_per_sample: How many bits the bridge has to sample |
| 78 | */ |
| 79 | struct soc_mbus_pixelfmt { |
| 80 | const char *name; |
| 81 | u32 fourcc; |
| 82 | enum soc_mbus_packing packing; |
| 83 | enum soc_mbus_order order; |
Laurent Pinchart | ad3b81f | 2012-03-21 08:03:23 -0300 | [diff] [blame] | 84 | enum soc_mbus_layout layout; |
Guennadi Liakhovetski | 9a74251 | 2009-12-11 11:41:28 -0300 | [diff] [blame] | 85 | u8 bits_per_sample; |
| 86 | }; |
| 87 | |
Guennadi Liakhovetski | 93f116d | 2011-05-13 13:21:36 -0300 | [diff] [blame] | 88 | /** |
| 89 | * struct soc_mbus_lookup - Lookup FOURCC IDs by mediabus codes for pass-through |
| 90 | * @code: mediabus pixel-code |
| 91 | * @fmt: pixel format description |
| 92 | */ |
| 93 | struct soc_mbus_lookup { |
Boris BREZILLON | 27ffaeb | 2014-11-10 14:28:31 -0300 | [diff] [blame] | 94 | u32 code; |
Guennadi Liakhovetski | 93f116d | 2011-05-13 13:21:36 -0300 | [diff] [blame] | 95 | struct soc_mbus_pixelfmt fmt; |
| 96 | }; |
| 97 | |
| 98 | const struct soc_mbus_pixelfmt *soc_mbus_find_fmtdesc( |
Boris BREZILLON | 27ffaeb | 2014-11-10 14:28:31 -0300 | [diff] [blame] | 99 | u32 code, |
Guennadi Liakhovetski | 93f116d | 2011-05-13 13:21:36 -0300 | [diff] [blame] | 100 | const struct soc_mbus_lookup *lookup, |
| 101 | int n); |
Guennadi Liakhovetski | 9a74251 | 2009-12-11 11:41:28 -0300 | [diff] [blame] | 102 | const struct soc_mbus_pixelfmt *soc_mbus_get_fmtdesc( |
Boris BREZILLON | 27ffaeb | 2014-11-10 14:28:31 -0300 | [diff] [blame] | 103 | u32 code); |
Guennadi Liakhovetski | 9a74251 | 2009-12-11 11:41:28 -0300 | [diff] [blame] | 104 | s32 soc_mbus_bytes_per_line(u32 width, const struct soc_mbus_pixelfmt *mf); |
Laurent Pinchart | 8929c96 | 2012-03-21 08:03:25 -0300 | [diff] [blame] | 105 | s32 soc_mbus_image_size(const struct soc_mbus_pixelfmt *mf, |
| 106 | u32 bytes_per_line, u32 height); |
Guennadi Liakhovetski | cc552b6 | 2011-05-20 04:25:09 -0300 | [diff] [blame] | 107 | int soc_mbus_samples_per_pixel(const struct soc_mbus_pixelfmt *mf, |
| 108 | unsigned int *numerator, unsigned int *denominator); |
Guennadi Liakhovetski | 32c69fcc | 2011-07-26 11:38:01 -0300 | [diff] [blame] | 109 | unsigned int soc_mbus_config_compatible(const struct v4l2_mbus_config *cfg, |
| 110 | unsigned int flags); |
Guennadi Liakhovetski | 9a74251 | 2009-12-11 11:41:28 -0300 | [diff] [blame] | 111 | |
| 112 | #endif |