1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Support for Intel Camera Imaging ISP subsystem.
4  * Copyright (c) 2015, Intel Corporation.
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms and conditions of the GNU General Public License,
8  * version 2, as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  */
15 
16 #include "sh_css_stream_format.h"
17 #include <ia_css_stream_format.h>
18 
sh_css_stream_format_2_bits_per_subpixel(enum atomisp_input_format format)19 unsigned int sh_css_stream_format_2_bits_per_subpixel(
20     enum atomisp_input_format format)
21 {
22 	unsigned int rval;
23 
24 	switch (format) {
25 	case ATOMISP_INPUT_FORMAT_RGB_444:
26 		rval = 4;
27 		break;
28 	case ATOMISP_INPUT_FORMAT_RGB_555:
29 		rval = 5;
30 		break;
31 	case ATOMISP_INPUT_FORMAT_RGB_565:
32 	case ATOMISP_INPUT_FORMAT_RGB_666:
33 	case ATOMISP_INPUT_FORMAT_RAW_6:
34 		rval = 6;
35 		break;
36 	case ATOMISP_INPUT_FORMAT_RAW_7:
37 		rval = 7;
38 		break;
39 	case ATOMISP_INPUT_FORMAT_YUV420_8_LEGACY:
40 	case ATOMISP_INPUT_FORMAT_YUV420_8:
41 	case ATOMISP_INPUT_FORMAT_YUV422_8:
42 	case ATOMISP_INPUT_FORMAT_RGB_888:
43 	case ATOMISP_INPUT_FORMAT_RAW_8:
44 	case ATOMISP_INPUT_FORMAT_BINARY_8:
45 	case ATOMISP_INPUT_FORMAT_USER_DEF1:
46 	case ATOMISP_INPUT_FORMAT_USER_DEF2:
47 	case ATOMISP_INPUT_FORMAT_USER_DEF3:
48 	case ATOMISP_INPUT_FORMAT_USER_DEF4:
49 	case ATOMISP_INPUT_FORMAT_USER_DEF5:
50 	case ATOMISP_INPUT_FORMAT_USER_DEF6:
51 	case ATOMISP_INPUT_FORMAT_USER_DEF7:
52 	case ATOMISP_INPUT_FORMAT_USER_DEF8:
53 		rval = 8;
54 		break;
55 	case ATOMISP_INPUT_FORMAT_YUV420_10:
56 	case ATOMISP_INPUT_FORMAT_YUV422_10:
57 	case ATOMISP_INPUT_FORMAT_RAW_10:
58 		rval = 10;
59 		break;
60 	case ATOMISP_INPUT_FORMAT_RAW_12:
61 		rval = 12;
62 		break;
63 	case ATOMISP_INPUT_FORMAT_RAW_14:
64 		rval = 14;
65 		break;
66 	case ATOMISP_INPUT_FORMAT_RAW_16:
67 	case ATOMISP_INPUT_FORMAT_YUV420_16:
68 	case ATOMISP_INPUT_FORMAT_YUV422_16:
69 		rval = 16;
70 		break;
71 	default:
72 		rval = 0;
73 		break;
74 	}
75 
76 	return rval;
77 }
78