summaryrefslogtreecommitdiffstats
path: root/include/drm
diff options
context:
space:
mode:
authorLiu Ying <Ying.liu@freescale.com>2015-11-20 03:15:30 -0500
committerThierry Reding <treding@nvidia.com>2015-11-23 03:07:38 -0500
commitec26d9e9382f432225d76b3ff1c7f72e21192f7f (patch)
tree191ef1d875c31fffe41cde969512f06f69c51dc5 /include/drm
parent8005c49d9aea74d382f474ce11afbbc7d7130bec (diff)
drm/dsi: Add a helper to get bits per pixel of MIPI DSI pixel format
Add a helper that can be used to obtain the number of bits per pixel corresponding to a given MIPI DSI pixel format. This is useful in bandwidth calculations, for example. Signed-off-by: Liu Ying <Ying.Liu@freescale.com> Acked-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Chris Zhong <zyw@rock-chips.com> [treding@nvidia.com: add kerneldoc comment and commit message] Signed-off-by: Thierry Reding <treding@nvidia.com>
Diffstat (limited to 'include/drm')
-rw-r--r--include/drm/drm_mipi_dsi.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h
index f1d8d0dbb4f1..4396c9f22af5 100644
--- a/include/drm/drm_mipi_dsi.h
+++ b/include/drm/drm_mipi_dsi.h
@@ -163,6 +163,31 @@ static inline struct mipi_dsi_device *to_mipi_dsi_device(struct device *dev)
163 return container_of(dev, struct mipi_dsi_device, dev); 163 return container_of(dev, struct mipi_dsi_device, dev);
164} 164}
165 165
166/**
167 * mipi_dsi_pixel_format_to_bpp - obtain the number of bits per pixel for any
168 * given pixel format defined by the MIPI DSI
169 * specification
170 * @fmt: MIPI DSI pixel format
171 *
172 * Returns: The number of bits per pixel of the given pixel format.
173 */
174static inline int mipi_dsi_pixel_format_to_bpp(enum mipi_dsi_pixel_format fmt)
175{
176 switch (fmt) {
177 case MIPI_DSI_FMT_RGB888:
178 case MIPI_DSI_FMT_RGB666:
179 return 24;
180
181 case MIPI_DSI_FMT_RGB666_PACKED:
182 return 18;
183
184 case MIPI_DSI_FMT_RGB565:
185 return 16;
186 }
187
188 return -EINVAL;
189}
190
166struct mipi_dsi_device *of_find_mipi_dsi_device_by_node(struct device_node *np); 191struct mipi_dsi_device *of_find_mipi_dsi_device_by_node(struct device_node *np);
167int mipi_dsi_attach(struct mipi_dsi_device *dsi); 192int mipi_dsi_attach(struct mipi_dsi_device *dsi);
168int mipi_dsi_detach(struct mipi_dsi_device *dsi); 193int mipi_dsi_detach(struct mipi_dsi_device *dsi);