| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (c) 2010 Sascha Hauer <s.hauer@pengutronix.de> |
|---|
| 3 | 4 | * Copyright (C) 2005-2009 Freescale Semiconductor, Inc. |
|---|
| 4 | | - * |
|---|
| 5 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 6 | | - * under the terms of the GNU General Public License as published by the |
|---|
| 7 | | - * Free Software Foundation; either version 2 of the License, or (at your |
|---|
| 8 | | - * option) any later version. |
|---|
| 9 | | - * |
|---|
| 10 | | - * This program is distributed in the hope that it will be useful, but |
|---|
| 11 | | - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
|---|
| 12 | | - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|---|
| 13 | | - * for more details. |
|---|
| 14 | 5 | */ |
|---|
| 15 | 6 | #include <linux/module.h> |
|---|
| 16 | 7 | #include <linux/export.h> |
|---|
| .. | .. |
|---|
| 122 | 113 | case V4L2_PIX_FMT_NV16: |
|---|
| 123 | 114 | case V4L2_PIX_FMT_NV61: |
|---|
| 124 | 115 | return IPUV3_COLORSPACE_YUV; |
|---|
| 125 | | - case V4L2_PIX_FMT_XRGB32: |
|---|
| 116 | + case V4L2_PIX_FMT_RGB565: |
|---|
| 117 | + case V4L2_PIX_FMT_BGR24: |
|---|
| 118 | + case V4L2_PIX_FMT_RGB24: |
|---|
| 119 | + case V4L2_PIX_FMT_ABGR32: |
|---|
| 126 | 120 | case V4L2_PIX_FMT_XBGR32: |
|---|
| 121 | + case V4L2_PIX_FMT_BGRA32: |
|---|
| 122 | + case V4L2_PIX_FMT_BGRX32: |
|---|
| 123 | + case V4L2_PIX_FMT_RGBA32: |
|---|
| 124 | + case V4L2_PIX_FMT_RGBX32: |
|---|
| 125 | + case V4L2_PIX_FMT_ARGB32: |
|---|
| 126 | + case V4L2_PIX_FMT_XRGB32: |
|---|
| 127 | 127 | case V4L2_PIX_FMT_RGB32: |
|---|
| 128 | 128 | case V4L2_PIX_FMT_BGR32: |
|---|
| 129 | | - case V4L2_PIX_FMT_RGB24: |
|---|
| 130 | | - case V4L2_PIX_FMT_BGR24: |
|---|
| 131 | | - case V4L2_PIX_FMT_RGB565: |
|---|
| 132 | 129 | return IPUV3_COLORSPACE_RGB; |
|---|
| 133 | 130 | default: |
|---|
| 134 | 131 | return IPUV3_COLORSPACE_UNKNOWN; |
|---|
| 135 | 132 | } |
|---|
| 136 | 133 | } |
|---|
| 137 | 134 | EXPORT_SYMBOL_GPL(ipu_pixelformat_to_colorspace); |
|---|
| 138 | | - |
|---|
| 139 | | -bool ipu_pixelformat_is_planar(u32 pixelformat) |
|---|
| 140 | | -{ |
|---|
| 141 | | - switch (pixelformat) { |
|---|
| 142 | | - case V4L2_PIX_FMT_YUV420: |
|---|
| 143 | | - case V4L2_PIX_FMT_YVU420: |
|---|
| 144 | | - case V4L2_PIX_FMT_YUV422P: |
|---|
| 145 | | - case V4L2_PIX_FMT_NV12: |
|---|
| 146 | | - case V4L2_PIX_FMT_NV21: |
|---|
| 147 | | - case V4L2_PIX_FMT_NV16: |
|---|
| 148 | | - case V4L2_PIX_FMT_NV61: |
|---|
| 149 | | - return true; |
|---|
| 150 | | - } |
|---|
| 151 | | - |
|---|
| 152 | | - return false; |
|---|
| 153 | | -} |
|---|
| 154 | | -EXPORT_SYMBOL_GPL(ipu_pixelformat_is_planar); |
|---|
| 155 | | - |
|---|
| 156 | | -enum ipu_color_space ipu_mbus_code_to_colorspace(u32 mbus_code) |
|---|
| 157 | | -{ |
|---|
| 158 | | - switch (mbus_code & 0xf000) { |
|---|
| 159 | | - case 0x1000: |
|---|
| 160 | | - return IPUV3_COLORSPACE_RGB; |
|---|
| 161 | | - case 0x2000: |
|---|
| 162 | | - return IPUV3_COLORSPACE_YUV; |
|---|
| 163 | | - default: |
|---|
| 164 | | - return IPUV3_COLORSPACE_UNKNOWN; |
|---|
| 165 | | - } |
|---|
| 166 | | -} |
|---|
| 167 | | -EXPORT_SYMBOL_GPL(ipu_mbus_code_to_colorspace); |
|---|
| 168 | | - |
|---|
| 169 | | -int ipu_stride_to_bytes(u32 pixel_stride, u32 pixelformat) |
|---|
| 170 | | -{ |
|---|
| 171 | | - switch (pixelformat) { |
|---|
| 172 | | - case V4L2_PIX_FMT_YUV420: |
|---|
| 173 | | - case V4L2_PIX_FMT_YVU420: |
|---|
| 174 | | - case V4L2_PIX_FMT_YUV422P: |
|---|
| 175 | | - case V4L2_PIX_FMT_NV12: |
|---|
| 176 | | - case V4L2_PIX_FMT_NV21: |
|---|
| 177 | | - case V4L2_PIX_FMT_NV16: |
|---|
| 178 | | - case V4L2_PIX_FMT_NV61: |
|---|
| 179 | | - /* |
|---|
| 180 | | - * for the planar YUV formats, the stride passed to |
|---|
| 181 | | - * cpmem must be the stride in bytes of the Y plane. |
|---|
| 182 | | - * And all the planar YUV formats have an 8-bit |
|---|
| 183 | | - * Y component. |
|---|
| 184 | | - */ |
|---|
| 185 | | - return (8 * pixel_stride) >> 3; |
|---|
| 186 | | - case V4L2_PIX_FMT_RGB565: |
|---|
| 187 | | - case V4L2_PIX_FMT_YUYV: |
|---|
| 188 | | - case V4L2_PIX_FMT_UYVY: |
|---|
| 189 | | - return (16 * pixel_stride) >> 3; |
|---|
| 190 | | - case V4L2_PIX_FMT_BGR24: |
|---|
| 191 | | - case V4L2_PIX_FMT_RGB24: |
|---|
| 192 | | - return (24 * pixel_stride) >> 3; |
|---|
| 193 | | - case V4L2_PIX_FMT_BGR32: |
|---|
| 194 | | - case V4L2_PIX_FMT_RGB32: |
|---|
| 195 | | - case V4L2_PIX_FMT_XBGR32: |
|---|
| 196 | | - case V4L2_PIX_FMT_XRGB32: |
|---|
| 197 | | - return (32 * pixel_stride) >> 3; |
|---|
| 198 | | - default: |
|---|
| 199 | | - break; |
|---|
| 200 | | - } |
|---|
| 201 | | - |
|---|
| 202 | | - return -EINVAL; |
|---|
| 203 | | -} |
|---|
| 204 | | -EXPORT_SYMBOL_GPL(ipu_stride_to_bytes); |
|---|
| 205 | 135 | |
|---|
| 206 | 136 | int ipu_degrees_to_rot_mode(enum ipu_rotate_mode *mode, int degrees, |
|---|
| 207 | 137 | bool hflip, bool vflip) |
|---|
| .. | .. |
|---|
| 1238 | 1168 | pdev = platform_device_alloc(reg->name, id++); |
|---|
| 1239 | 1169 | if (!pdev) { |
|---|
| 1240 | 1170 | ret = -ENOMEM; |
|---|
| 1171 | + of_node_put(of_node); |
|---|
| 1241 | 1172 | goto err_register; |
|---|
| 1242 | 1173 | } |
|---|
| 1243 | 1174 | |
|---|