| .. | .. |
|---|
| 813 | 813 | #define COLOR_FMT_P010_UBWC COLOR_FMT_P010_UBWC |
|---|
| 814 | 814 | #define COLOR_FMT_P010 COLOR_FMT_P010 |
|---|
| 815 | 815 | |
|---|
| 816 | | -static inline unsigned int VENUS_EXTRADATA_SIZE(int width, int height) |
|---|
| 817 | | -{ |
|---|
| 818 | | - (void)height; |
|---|
| 819 | | - (void)width; |
|---|
| 820 | | - |
|---|
| 821 | | - /* |
|---|
| 822 | | - * In the future, calculate the size based on the w/h but just |
|---|
| 823 | | - * hardcode it for now since 16K satisfies all current usecases. |
|---|
| 824 | | - */ |
|---|
| 825 | | - return 16 * 1024; |
|---|
| 826 | | -} |
|---|
| 827 | | - |
|---|
| 828 | 816 | /* |
|---|
| 829 | 817 | * Function arguments: |
|---|
| 830 | 818 | * @color_fmt |
|---|
| .. | .. |
|---|
| 832 | 820 | * Progressive: width |
|---|
| 833 | 821 | * Interlaced: width |
|---|
| 834 | 822 | */ |
|---|
| 835 | | -static inline unsigned int VENUS_Y_STRIDE(int color_fmt, int width) |
|---|
| 823 | +static unsigned int VENUS_Y_STRIDE(int color_fmt, int width) |
|---|
| 836 | 824 | { |
|---|
| 837 | | - unsigned int alignment, stride = 0; |
|---|
| 825 | + unsigned int stride = 0; |
|---|
| 838 | 826 | |
|---|
| 839 | 827 | if (!width) |
|---|
| 840 | | - goto invalid_input; |
|---|
| 841 | | - |
|---|
| 842 | | - switch (color_fmt) { |
|---|
| 843 | | - case COLOR_FMT_NV21: |
|---|
| 844 | | - case COLOR_FMT_NV12: |
|---|
| 845 | | - case COLOR_FMT_NV12_MVTB: |
|---|
| 846 | | - case COLOR_FMT_NV12_UBWC: |
|---|
| 847 | | - alignment = 128; |
|---|
| 848 | | - stride = MSM_MEDIA_ALIGN(width, alignment); |
|---|
| 849 | | - break; |
|---|
| 850 | | - case COLOR_FMT_NV12_BPP10_UBWC: |
|---|
| 851 | | - alignment = 256; |
|---|
| 852 | | - stride = MSM_MEDIA_ALIGN(width, 192); |
|---|
| 853 | | - stride = MSM_MEDIA_ALIGN(stride * 4/3, alignment); |
|---|
| 854 | | - break; |
|---|
| 855 | | - case COLOR_FMT_P010_UBWC: |
|---|
| 856 | | - alignment = 256; |
|---|
| 857 | | - stride = MSM_MEDIA_ALIGN(width * 2, alignment); |
|---|
| 858 | | - break; |
|---|
| 859 | | - case COLOR_FMT_P010: |
|---|
| 860 | | - alignment = 128; |
|---|
| 861 | | - stride = MSM_MEDIA_ALIGN(width*2, alignment); |
|---|
| 862 | | - break; |
|---|
| 863 | | - default: |
|---|
| 864 | | - break; |
|---|
| 865 | | - } |
|---|
| 866 | | -invalid_input: |
|---|
| 867 | | - return stride; |
|---|
| 868 | | -} |
|---|
| 869 | | - |
|---|
| 870 | | -/* |
|---|
| 871 | | - * Function arguments: |
|---|
| 872 | | - * @color_fmt |
|---|
| 873 | | - * @width |
|---|
| 874 | | - * Progressive: width |
|---|
| 875 | | - * Interlaced: width |
|---|
| 876 | | - */ |
|---|
| 877 | | -static inline unsigned int VENUS_UV_STRIDE(int color_fmt, int width) |
|---|
| 878 | | -{ |
|---|
| 879 | | - unsigned int alignment, stride = 0; |
|---|
| 880 | | - |
|---|
| 881 | | - if (!width) |
|---|
| 882 | | - goto invalid_input; |
|---|
| 883 | | - |
|---|
| 884 | | - switch (color_fmt) { |
|---|
| 885 | | - case COLOR_FMT_NV21: |
|---|
| 886 | | - case COLOR_FMT_NV12: |
|---|
| 887 | | - case COLOR_FMT_NV12_MVTB: |
|---|
| 888 | | - case COLOR_FMT_NV12_UBWC: |
|---|
| 889 | | - alignment = 128; |
|---|
| 890 | | - stride = MSM_MEDIA_ALIGN(width, alignment); |
|---|
| 891 | | - break; |
|---|
| 892 | | - case COLOR_FMT_NV12_BPP10_UBWC: |
|---|
| 893 | | - alignment = 256; |
|---|
| 894 | | - stride = MSM_MEDIA_ALIGN(width, 192); |
|---|
| 895 | | - stride = MSM_MEDIA_ALIGN(stride * 4/3, alignment); |
|---|
| 896 | | - break; |
|---|
| 897 | | - case COLOR_FMT_P010_UBWC: |
|---|
| 898 | | - alignment = 256; |
|---|
| 899 | | - stride = MSM_MEDIA_ALIGN(width * 2, alignment); |
|---|
| 900 | | - break; |
|---|
| 901 | | - case COLOR_FMT_P010: |
|---|
| 902 | | - alignment = 128; |
|---|
| 903 | | - stride = MSM_MEDIA_ALIGN(width*2, alignment); |
|---|
| 904 | | - break; |
|---|
| 905 | | - default: |
|---|
| 906 | | - break; |
|---|
| 907 | | - } |
|---|
| 908 | | -invalid_input: |
|---|
| 909 | | - return stride; |
|---|
| 910 | | -} |
|---|
| 911 | | - |
|---|
| 912 | | -/* |
|---|
| 913 | | - * Function arguments: |
|---|
| 914 | | - * @color_fmt |
|---|
| 915 | | - * @height |
|---|
| 916 | | - * Progressive: height |
|---|
| 917 | | - * Interlaced: (height+1)>>1 |
|---|
| 918 | | - */ |
|---|
| 919 | | -static inline unsigned int VENUS_Y_SCANLINES(int color_fmt, int height) |
|---|
| 920 | | -{ |
|---|
| 921 | | - unsigned int alignment, sclines = 0; |
|---|
| 922 | | - |
|---|
| 923 | | - if (!height) |
|---|
| 924 | | - goto invalid_input; |
|---|
| 925 | | - |
|---|
| 926 | | - switch (color_fmt) { |
|---|
| 927 | | - case COLOR_FMT_NV21: |
|---|
| 928 | | - case COLOR_FMT_NV12: |
|---|
| 929 | | - case COLOR_FMT_NV12_MVTB: |
|---|
| 930 | | - case COLOR_FMT_NV12_UBWC: |
|---|
| 931 | | - case COLOR_FMT_P010: |
|---|
| 932 | | - alignment = 32; |
|---|
| 933 | | - break; |
|---|
| 934 | | - case COLOR_FMT_NV12_BPP10_UBWC: |
|---|
| 935 | | - case COLOR_FMT_P010_UBWC: |
|---|
| 936 | | - alignment = 16; |
|---|
| 937 | | - break; |
|---|
| 938 | | - default: |
|---|
| 939 | 828 | return 0; |
|---|
| 829 | + |
|---|
| 830 | + switch (color_fmt) { |
|---|
| 831 | + case COLOR_FMT_NV21: |
|---|
| 832 | + case COLOR_FMT_NV12: |
|---|
| 833 | + case COLOR_FMT_NV12_MVTB: |
|---|
| 834 | + case COLOR_FMT_NV12_UBWC: |
|---|
| 835 | + stride = MSM_MEDIA_ALIGN(width, 128); |
|---|
| 836 | + break; |
|---|
| 837 | + case COLOR_FMT_NV12_BPP10_UBWC: |
|---|
| 838 | + stride = MSM_MEDIA_ALIGN(width, 192); |
|---|
| 839 | + stride = MSM_MEDIA_ALIGN(stride * 4 / 3, 256); |
|---|
| 840 | + break; |
|---|
| 841 | + case COLOR_FMT_P010_UBWC: |
|---|
| 842 | + stride = MSM_MEDIA_ALIGN(width * 2, 256); |
|---|
| 843 | + break; |
|---|
| 844 | + case COLOR_FMT_P010: |
|---|
| 845 | + stride = MSM_MEDIA_ALIGN(width * 2, 128); |
|---|
| 846 | + break; |
|---|
| 940 | 847 | } |
|---|
| 941 | | - sclines = MSM_MEDIA_ALIGN(height, alignment); |
|---|
| 942 | | -invalid_input: |
|---|
| 848 | + |
|---|
| 849 | + return stride; |
|---|
| 850 | +} |
|---|
| 851 | + |
|---|
| 852 | +/* |
|---|
| 853 | + * Function arguments: |
|---|
| 854 | + * @color_fmt |
|---|
| 855 | + * @width |
|---|
| 856 | + * Progressive: width |
|---|
| 857 | + * Interlaced: width |
|---|
| 858 | + */ |
|---|
| 859 | +static unsigned int VENUS_UV_STRIDE(int color_fmt, int width) |
|---|
| 860 | +{ |
|---|
| 861 | + unsigned int stride = 0; |
|---|
| 862 | + |
|---|
| 863 | + if (!width) |
|---|
| 864 | + return 0; |
|---|
| 865 | + |
|---|
| 866 | + switch (color_fmt) { |
|---|
| 867 | + case COLOR_FMT_NV21: |
|---|
| 868 | + case COLOR_FMT_NV12: |
|---|
| 869 | + case COLOR_FMT_NV12_MVTB: |
|---|
| 870 | + case COLOR_FMT_NV12_UBWC: |
|---|
| 871 | + stride = MSM_MEDIA_ALIGN(width, 128); |
|---|
| 872 | + break; |
|---|
| 873 | + case COLOR_FMT_NV12_BPP10_UBWC: |
|---|
| 874 | + stride = MSM_MEDIA_ALIGN(width, 192); |
|---|
| 875 | + stride = MSM_MEDIA_ALIGN(stride * 4 / 3, 256); |
|---|
| 876 | + break; |
|---|
| 877 | + case COLOR_FMT_P010_UBWC: |
|---|
| 878 | + stride = MSM_MEDIA_ALIGN(width * 2, 256); |
|---|
| 879 | + break; |
|---|
| 880 | + case COLOR_FMT_P010: |
|---|
| 881 | + stride = MSM_MEDIA_ALIGN(width * 2, 128); |
|---|
| 882 | + break; |
|---|
| 883 | + } |
|---|
| 884 | + |
|---|
| 885 | + return stride; |
|---|
| 886 | +} |
|---|
| 887 | + |
|---|
| 888 | +/* |
|---|
| 889 | + * Function arguments: |
|---|
| 890 | + * @color_fmt |
|---|
| 891 | + * @height |
|---|
| 892 | + * Progressive: height |
|---|
| 893 | + * Interlaced: (height+1)>>1 |
|---|
| 894 | + */ |
|---|
| 895 | +static unsigned int VENUS_Y_SCANLINES(int color_fmt, int height) |
|---|
| 896 | +{ |
|---|
| 897 | + unsigned int sclines = 0; |
|---|
| 898 | + |
|---|
| 899 | + if (!height) |
|---|
| 900 | + return 0; |
|---|
| 901 | + |
|---|
| 902 | + switch (color_fmt) { |
|---|
| 903 | + case COLOR_FMT_NV21: |
|---|
| 904 | + case COLOR_FMT_NV12: |
|---|
| 905 | + case COLOR_FMT_NV12_MVTB: |
|---|
| 906 | + case COLOR_FMT_NV12_UBWC: |
|---|
| 907 | + case COLOR_FMT_P010: |
|---|
| 908 | + sclines = MSM_MEDIA_ALIGN(height, 32); |
|---|
| 909 | + break; |
|---|
| 910 | + case COLOR_FMT_NV12_BPP10_UBWC: |
|---|
| 911 | + case COLOR_FMT_P010_UBWC: |
|---|
| 912 | + sclines = MSM_MEDIA_ALIGN(height, 16); |
|---|
| 913 | + break; |
|---|
| 914 | + } |
|---|
| 915 | + |
|---|
| 943 | 916 | return sclines; |
|---|
| 944 | 917 | } |
|---|
| 945 | 918 | |
|---|
| .. | .. |
|---|
| 950 | 923 | * Progressive: height |
|---|
| 951 | 924 | * Interlaced: (height+1)>>1 |
|---|
| 952 | 925 | */ |
|---|
| 953 | | -static inline unsigned int VENUS_UV_SCANLINES(int color_fmt, int height) |
|---|
| 926 | +static unsigned int VENUS_UV_SCANLINES(int color_fmt, int height) |
|---|
| 954 | 927 | { |
|---|
| 955 | | - unsigned int alignment, sclines = 0; |
|---|
| 928 | + unsigned int sclines = 0; |
|---|
| 956 | 929 | |
|---|
| 957 | 930 | if (!height) |
|---|
| 958 | | - goto invalid_input; |
|---|
| 931 | + return 0; |
|---|
| 959 | 932 | |
|---|
| 960 | 933 | switch (color_fmt) { |
|---|
| 961 | 934 | case COLOR_FMT_NV21: |
|---|
| .. | .. |
|---|
| 964 | 937 | case COLOR_FMT_NV12_BPP10_UBWC: |
|---|
| 965 | 938 | case COLOR_FMT_P010_UBWC: |
|---|
| 966 | 939 | case COLOR_FMT_P010: |
|---|
| 967 | | - alignment = 16; |
|---|
| 940 | + sclines = MSM_MEDIA_ALIGN((height + 1) >> 1, 16); |
|---|
| 968 | 941 | break; |
|---|
| 969 | 942 | case COLOR_FMT_NV12_UBWC: |
|---|
| 970 | | - alignment = 32; |
|---|
| 943 | + sclines = MSM_MEDIA_ALIGN((height + 1) >> 1, 32); |
|---|
| 971 | 944 | break; |
|---|
| 972 | | - default: |
|---|
| 973 | | - goto invalid_input; |
|---|
| 974 | 945 | } |
|---|
| 975 | 946 | |
|---|
| 976 | | - sclines = MSM_MEDIA_ALIGN((height+1)>>1, alignment); |
|---|
| 977 | | - |
|---|
| 978 | | -invalid_input: |
|---|
| 979 | 947 | return sclines; |
|---|
| 980 | 948 | } |
|---|
| 981 | 949 | |
|---|
| .. | .. |
|---|
| 986 | 954 | * Progressive: width |
|---|
| 987 | 955 | * Interlaced: width |
|---|
| 988 | 956 | */ |
|---|
| 989 | | -static inline unsigned int VENUS_Y_META_STRIDE(int color_fmt, int width) |
|---|
| 957 | +static unsigned int VENUS_Y_META_STRIDE(int color_fmt, int width) |
|---|
| 990 | 958 | { |
|---|
| 991 | | - int y_tile_width = 0, y_meta_stride = 0; |
|---|
| 959 | + int y_tile_width = 0, y_meta_stride; |
|---|
| 992 | 960 | |
|---|
| 993 | 961 | if (!width) |
|---|
| 994 | | - goto invalid_input; |
|---|
| 962 | + return 0; |
|---|
| 995 | 963 | |
|---|
| 996 | 964 | switch (color_fmt) { |
|---|
| 997 | 965 | case COLOR_FMT_NV12_UBWC: |
|---|
| .. | .. |
|---|
| 1002 | 970 | y_tile_width = 48; |
|---|
| 1003 | 971 | break; |
|---|
| 1004 | 972 | default: |
|---|
| 1005 | | - goto invalid_input; |
|---|
| 973 | + return 0; |
|---|
| 1006 | 974 | } |
|---|
| 1007 | 975 | |
|---|
| 1008 | 976 | y_meta_stride = MSM_MEDIA_ROUNDUP(width, y_tile_width); |
|---|
| 1009 | | - y_meta_stride = MSM_MEDIA_ALIGN(y_meta_stride, 64); |
|---|
| 1010 | | - |
|---|
| 1011 | | -invalid_input: |
|---|
| 1012 | | - return y_meta_stride; |
|---|
| 977 | + return MSM_MEDIA_ALIGN(y_meta_stride, 64); |
|---|
| 1013 | 978 | } |
|---|
| 1014 | 979 | |
|---|
| 1015 | 980 | /* |
|---|
| .. | .. |
|---|
| 1019 | 984 | * Progressive: height |
|---|
| 1020 | 985 | * Interlaced: (height+1)>>1 |
|---|
| 1021 | 986 | */ |
|---|
| 1022 | | -static inline unsigned int VENUS_Y_META_SCANLINES(int color_fmt, int height) |
|---|
| 987 | +static unsigned int VENUS_Y_META_SCANLINES(int color_fmt, int height) |
|---|
| 1023 | 988 | { |
|---|
| 1024 | | - int y_tile_height = 0, y_meta_scanlines = 0; |
|---|
| 989 | + int y_tile_height = 0, y_meta_scanlines; |
|---|
| 1025 | 990 | |
|---|
| 1026 | 991 | if (!height) |
|---|
| 1027 | | - goto invalid_input; |
|---|
| 992 | + return 0; |
|---|
| 1028 | 993 | |
|---|
| 1029 | 994 | switch (color_fmt) { |
|---|
| 1030 | 995 | case COLOR_FMT_NV12_UBWC: |
|---|
| .. | .. |
|---|
| 1035 | 1000 | y_tile_height = 4; |
|---|
| 1036 | 1001 | break; |
|---|
| 1037 | 1002 | default: |
|---|
| 1038 | | - goto invalid_input; |
|---|
| 1003 | + return 0; |
|---|
| 1039 | 1004 | } |
|---|
| 1040 | 1005 | |
|---|
| 1041 | 1006 | y_meta_scanlines = MSM_MEDIA_ROUNDUP(height, y_tile_height); |
|---|
| 1042 | | - y_meta_scanlines = MSM_MEDIA_ALIGN(y_meta_scanlines, 16); |
|---|
| 1043 | | - |
|---|
| 1044 | | -invalid_input: |
|---|
| 1045 | | - return y_meta_scanlines; |
|---|
| 1007 | + return MSM_MEDIA_ALIGN(y_meta_scanlines, 16); |
|---|
| 1046 | 1008 | } |
|---|
| 1047 | 1009 | |
|---|
| 1048 | 1010 | /* |
|---|
| .. | .. |
|---|
| 1052 | 1014 | * Progressive: width |
|---|
| 1053 | 1015 | * Interlaced: width |
|---|
| 1054 | 1016 | */ |
|---|
| 1055 | | -static inline unsigned int VENUS_UV_META_STRIDE(int color_fmt, int width) |
|---|
| 1017 | +static unsigned int VENUS_UV_META_STRIDE(int color_fmt, int width) |
|---|
| 1056 | 1018 | { |
|---|
| 1057 | | - int uv_tile_width = 0, uv_meta_stride = 0; |
|---|
| 1019 | + int uv_tile_width = 0, uv_meta_stride; |
|---|
| 1058 | 1020 | |
|---|
| 1059 | 1021 | if (!width) |
|---|
| 1060 | | - goto invalid_input; |
|---|
| 1022 | + return 0; |
|---|
| 1061 | 1023 | |
|---|
| 1062 | 1024 | switch (color_fmt) { |
|---|
| 1063 | 1025 | case COLOR_FMT_NV12_UBWC: |
|---|
| .. | .. |
|---|
| 1068 | 1030 | uv_tile_width = 24; |
|---|
| 1069 | 1031 | break; |
|---|
| 1070 | 1032 | default: |
|---|
| 1071 | | - goto invalid_input; |
|---|
| 1033 | + return 0; |
|---|
| 1072 | 1034 | } |
|---|
| 1073 | 1035 | |
|---|
| 1074 | 1036 | uv_meta_stride = MSM_MEDIA_ROUNDUP((width+1)>>1, uv_tile_width); |
|---|
| 1075 | | - uv_meta_stride = MSM_MEDIA_ALIGN(uv_meta_stride, 64); |
|---|
| 1076 | | - |
|---|
| 1077 | | -invalid_input: |
|---|
| 1078 | | - return uv_meta_stride; |
|---|
| 1037 | + return MSM_MEDIA_ALIGN(uv_meta_stride, 64); |
|---|
| 1079 | 1038 | } |
|---|
| 1080 | 1039 | |
|---|
| 1081 | 1040 | /* |
|---|
| .. | .. |
|---|
| 1085 | 1044 | * Progressive: height |
|---|
| 1086 | 1045 | * Interlaced: (height+1)>>1 |
|---|
| 1087 | 1046 | */ |
|---|
| 1088 | | -static inline unsigned int VENUS_UV_META_SCANLINES(int color_fmt, int height) |
|---|
| 1047 | +static unsigned int VENUS_UV_META_SCANLINES(int color_fmt, int height) |
|---|
| 1089 | 1048 | { |
|---|
| 1090 | | - int uv_tile_height = 0, uv_meta_scanlines = 0; |
|---|
| 1049 | + int uv_tile_height = 0, uv_meta_scanlines; |
|---|
| 1091 | 1050 | |
|---|
| 1092 | 1051 | if (!height) |
|---|
| 1093 | | - goto invalid_input; |
|---|
| 1052 | + return 0; |
|---|
| 1094 | 1053 | |
|---|
| 1095 | 1054 | switch (color_fmt) { |
|---|
| 1096 | 1055 | case COLOR_FMT_NV12_UBWC: |
|---|
| .. | .. |
|---|
| 1101 | 1060 | uv_tile_height = 4; |
|---|
| 1102 | 1061 | break; |
|---|
| 1103 | 1062 | default: |
|---|
| 1104 | | - goto invalid_input; |
|---|
| 1063 | + return 0; |
|---|
| 1105 | 1064 | } |
|---|
| 1106 | 1065 | |
|---|
| 1107 | 1066 | uv_meta_scanlines = MSM_MEDIA_ROUNDUP((height+1)>>1, uv_tile_height); |
|---|
| 1108 | | - uv_meta_scanlines = MSM_MEDIA_ALIGN(uv_meta_scanlines, 16); |
|---|
| 1109 | | - |
|---|
| 1110 | | -invalid_input: |
|---|
| 1111 | | - return uv_meta_scanlines; |
|---|
| 1067 | + return MSM_MEDIA_ALIGN(uv_meta_scanlines, 16); |
|---|
| 1112 | 1068 | } |
|---|
| 1113 | 1069 | |
|---|
| 1114 | | -static inline unsigned int VENUS_RGB_STRIDE(int color_fmt, int width) |
|---|
| 1070 | +static unsigned int VENUS_RGB_STRIDE(int color_fmt, int width) |
|---|
| 1115 | 1071 | { |
|---|
| 1116 | | - unsigned int alignment = 0, stride = 0, bpp = 4; |
|---|
| 1072 | + unsigned int alignment = 0, bpp = 4; |
|---|
| 1117 | 1073 | |
|---|
| 1118 | 1074 | if (!width) |
|---|
| 1119 | | - goto invalid_input; |
|---|
| 1075 | + return 0; |
|---|
| 1120 | 1076 | |
|---|
| 1121 | 1077 | switch (color_fmt) { |
|---|
| 1122 | 1078 | case COLOR_FMT_RGBA8888: |
|---|
| .. | .. |
|---|
| 1131 | 1087 | alignment = 256; |
|---|
| 1132 | 1088 | break; |
|---|
| 1133 | 1089 | default: |
|---|
| 1134 | | - goto invalid_input; |
|---|
| 1090 | + return 0; |
|---|
| 1135 | 1091 | } |
|---|
| 1136 | 1092 | |
|---|
| 1137 | | - stride = MSM_MEDIA_ALIGN(width * bpp, alignment); |
|---|
| 1138 | | - |
|---|
| 1139 | | -invalid_input: |
|---|
| 1140 | | - return stride; |
|---|
| 1093 | + return MSM_MEDIA_ALIGN(width * bpp, alignment); |
|---|
| 1141 | 1094 | } |
|---|
| 1142 | 1095 | |
|---|
| 1143 | | -static inline unsigned int VENUS_RGB_SCANLINES(int color_fmt, int height) |
|---|
| 1096 | +static unsigned int VENUS_RGB_SCANLINES(int color_fmt, int height) |
|---|
| 1144 | 1097 | { |
|---|
| 1145 | | - unsigned int alignment = 0, scanlines = 0; |
|---|
| 1098 | + unsigned int alignment = 0; |
|---|
| 1146 | 1099 | |
|---|
| 1147 | 1100 | if (!height) |
|---|
| 1148 | | - goto invalid_input; |
|---|
| 1101 | + return 0; |
|---|
| 1149 | 1102 | |
|---|
| 1150 | 1103 | switch (color_fmt) { |
|---|
| 1151 | 1104 | case COLOR_FMT_RGBA8888: |
|---|
| .. | .. |
|---|
| 1157 | 1110 | alignment = 16; |
|---|
| 1158 | 1111 | break; |
|---|
| 1159 | 1112 | default: |
|---|
| 1160 | | - goto invalid_input; |
|---|
| 1113 | + return 0; |
|---|
| 1161 | 1114 | } |
|---|
| 1162 | 1115 | |
|---|
| 1163 | | - scanlines = MSM_MEDIA_ALIGN(height, alignment); |
|---|
| 1164 | | - |
|---|
| 1165 | | -invalid_input: |
|---|
| 1166 | | - return scanlines; |
|---|
| 1116 | + return MSM_MEDIA_ALIGN(height, alignment); |
|---|
| 1167 | 1117 | } |
|---|
| 1168 | 1118 | |
|---|
| 1169 | | -static inline unsigned int VENUS_RGB_META_STRIDE(int color_fmt, int width) |
|---|
| 1119 | +static unsigned int VENUS_RGB_META_STRIDE(int color_fmt, int width) |
|---|
| 1170 | 1120 | { |
|---|
| 1171 | | - int rgb_tile_width = 0, rgb_meta_stride = 0; |
|---|
| 1121 | + int rgb_meta_stride; |
|---|
| 1172 | 1122 | |
|---|
| 1173 | 1123 | if (!width) |
|---|
| 1174 | | - goto invalid_input; |
|---|
| 1124 | + return 0; |
|---|
| 1175 | 1125 | |
|---|
| 1176 | 1126 | switch (color_fmt) { |
|---|
| 1177 | 1127 | case COLOR_FMT_RGBA8888_UBWC: |
|---|
| 1178 | 1128 | case COLOR_FMT_RGBA1010102_UBWC: |
|---|
| 1179 | 1129 | case COLOR_FMT_RGB565_UBWC: |
|---|
| 1180 | | - rgb_tile_width = 16; |
|---|
| 1181 | | - break; |
|---|
| 1182 | | - default: |
|---|
| 1183 | | - goto invalid_input; |
|---|
| 1130 | + rgb_meta_stride = MSM_MEDIA_ROUNDUP(width, 16); |
|---|
| 1131 | + return MSM_MEDIA_ALIGN(rgb_meta_stride, 64); |
|---|
| 1184 | 1132 | } |
|---|
| 1185 | 1133 | |
|---|
| 1186 | | - rgb_meta_stride = MSM_MEDIA_ROUNDUP(width, rgb_tile_width); |
|---|
| 1187 | | - rgb_meta_stride = MSM_MEDIA_ALIGN(rgb_meta_stride, 64); |
|---|
| 1188 | | - |
|---|
| 1189 | | -invalid_input: |
|---|
| 1190 | | - return rgb_meta_stride; |
|---|
| 1134 | + return 0; |
|---|
| 1191 | 1135 | } |
|---|
| 1192 | 1136 | |
|---|
| 1193 | | -static inline unsigned int VENUS_RGB_META_SCANLINES(int color_fmt, int height) |
|---|
| 1137 | +static unsigned int VENUS_RGB_META_SCANLINES(int color_fmt, int height) |
|---|
| 1194 | 1138 | { |
|---|
| 1195 | | - int rgb_tile_height = 0, rgb_meta_scanlines = 0; |
|---|
| 1139 | + int rgb_meta_scanlines; |
|---|
| 1196 | 1140 | |
|---|
| 1197 | 1141 | if (!height) |
|---|
| 1198 | | - goto invalid_input; |
|---|
| 1142 | + return 0; |
|---|
| 1199 | 1143 | |
|---|
| 1200 | 1144 | switch (color_fmt) { |
|---|
| 1201 | 1145 | case COLOR_FMT_RGBA8888_UBWC: |
|---|
| 1202 | 1146 | case COLOR_FMT_RGBA1010102_UBWC: |
|---|
| 1203 | 1147 | case COLOR_FMT_RGB565_UBWC: |
|---|
| 1204 | | - rgb_tile_height = 4; |
|---|
| 1205 | | - break; |
|---|
| 1206 | | - default: |
|---|
| 1207 | | - goto invalid_input; |
|---|
| 1148 | + rgb_meta_scanlines = MSM_MEDIA_ROUNDUP(height, 4); |
|---|
| 1149 | + return MSM_MEDIA_ALIGN(rgb_meta_scanlines, 16); |
|---|
| 1208 | 1150 | } |
|---|
| 1209 | 1151 | |
|---|
| 1210 | | - rgb_meta_scanlines = MSM_MEDIA_ROUNDUP(height, rgb_tile_height); |
|---|
| 1211 | | - rgb_meta_scanlines = MSM_MEDIA_ALIGN(rgb_meta_scanlines, 16); |
|---|
| 1212 | | - |
|---|
| 1213 | | -invalid_input: |
|---|
| 1214 | | - return rgb_meta_scanlines; |
|---|
| 1215 | | -} |
|---|
| 1216 | | - |
|---|
| 1217 | | -/* |
|---|
| 1218 | | - * Function arguments: |
|---|
| 1219 | | - * @color_fmt |
|---|
| 1220 | | - * @width |
|---|
| 1221 | | - * Progressive: width |
|---|
| 1222 | | - * Interlaced: width |
|---|
| 1223 | | - * @height |
|---|
| 1224 | | - * Progressive: height |
|---|
| 1225 | | - * Interlaced: height |
|---|
| 1226 | | - */ |
|---|
| 1227 | | -static inline unsigned int VENUS_BUFFER_SIZE( |
|---|
| 1228 | | - int color_fmt, int width, int height) |
|---|
| 1229 | | -{ |
|---|
| 1230 | | - const unsigned int extra_size = VENUS_EXTRADATA_SIZE(width, height); |
|---|
| 1231 | | - unsigned int uv_alignment = 0, size = 0; |
|---|
| 1232 | | - unsigned int y_plane, uv_plane, y_stride, |
|---|
| 1233 | | - uv_stride, y_sclines, uv_sclines; |
|---|
| 1234 | | - unsigned int y_ubwc_plane = 0, uv_ubwc_plane = 0; |
|---|
| 1235 | | - unsigned int y_meta_stride = 0, y_meta_scanlines = 0; |
|---|
| 1236 | | - unsigned int uv_meta_stride = 0, uv_meta_scanlines = 0; |
|---|
| 1237 | | - unsigned int y_meta_plane = 0, uv_meta_plane = 0; |
|---|
| 1238 | | - unsigned int rgb_stride = 0, rgb_scanlines = 0; |
|---|
| 1239 | | - unsigned int rgb_plane = 0, rgb_ubwc_plane = 0, rgb_meta_plane = 0; |
|---|
| 1240 | | - unsigned int rgb_meta_stride = 0, rgb_meta_scanlines = 0; |
|---|
| 1241 | | - |
|---|
| 1242 | | - if (!width || !height) |
|---|
| 1243 | | - goto invalid_input; |
|---|
| 1244 | | - |
|---|
| 1245 | | - y_stride = VENUS_Y_STRIDE(color_fmt, width); |
|---|
| 1246 | | - uv_stride = VENUS_UV_STRIDE(color_fmt, width); |
|---|
| 1247 | | - y_sclines = VENUS_Y_SCANLINES(color_fmt, height); |
|---|
| 1248 | | - uv_sclines = VENUS_UV_SCANLINES(color_fmt, height); |
|---|
| 1249 | | - rgb_stride = VENUS_RGB_STRIDE(color_fmt, width); |
|---|
| 1250 | | - rgb_scanlines = VENUS_RGB_SCANLINES(color_fmt, height); |
|---|
| 1251 | | - |
|---|
| 1252 | | - switch (color_fmt) { |
|---|
| 1253 | | - case COLOR_FMT_NV21: |
|---|
| 1254 | | - case COLOR_FMT_NV12: |
|---|
| 1255 | | - case COLOR_FMT_P010: |
|---|
| 1256 | | - uv_alignment = 4096; |
|---|
| 1257 | | - y_plane = y_stride * y_sclines; |
|---|
| 1258 | | - uv_plane = uv_stride * uv_sclines + uv_alignment; |
|---|
| 1259 | | - size = y_plane + uv_plane + |
|---|
| 1260 | | - MSM_MEDIA_MAX(extra_size, 8 * y_stride); |
|---|
| 1261 | | - size = MSM_MEDIA_ALIGN(size, 4096); |
|---|
| 1262 | | - break; |
|---|
| 1263 | | - case COLOR_FMT_NV12_MVTB: |
|---|
| 1264 | | - uv_alignment = 4096; |
|---|
| 1265 | | - y_plane = y_stride * y_sclines; |
|---|
| 1266 | | - uv_plane = uv_stride * uv_sclines + uv_alignment; |
|---|
| 1267 | | - size = y_plane + uv_plane; |
|---|
| 1268 | | - size = 2 * size + extra_size; |
|---|
| 1269 | | - size = MSM_MEDIA_ALIGN(size, 4096); |
|---|
| 1270 | | - break; |
|---|
| 1271 | | - case COLOR_FMT_NV12_UBWC: |
|---|
| 1272 | | - y_sclines = VENUS_Y_SCANLINES(color_fmt, (height+1)>>1); |
|---|
| 1273 | | - y_ubwc_plane = MSM_MEDIA_ALIGN(y_stride * y_sclines, 4096); |
|---|
| 1274 | | - uv_sclines = VENUS_UV_SCANLINES(color_fmt, (height+1)>>1); |
|---|
| 1275 | | - uv_ubwc_plane = MSM_MEDIA_ALIGN(uv_stride * uv_sclines, 4096); |
|---|
| 1276 | | - y_meta_stride = VENUS_Y_META_STRIDE(color_fmt, width); |
|---|
| 1277 | | - y_meta_scanlines = |
|---|
| 1278 | | - VENUS_Y_META_SCANLINES(color_fmt, (height+1)>>1); |
|---|
| 1279 | | - y_meta_plane = MSM_MEDIA_ALIGN( |
|---|
| 1280 | | - y_meta_stride * y_meta_scanlines, 4096); |
|---|
| 1281 | | - uv_meta_stride = VENUS_UV_META_STRIDE(color_fmt, width); |
|---|
| 1282 | | - uv_meta_scanlines = |
|---|
| 1283 | | - VENUS_UV_META_SCANLINES(color_fmt, (height+1)>>1); |
|---|
| 1284 | | - uv_meta_plane = MSM_MEDIA_ALIGN(uv_meta_stride * |
|---|
| 1285 | | - uv_meta_scanlines, 4096); |
|---|
| 1286 | | - |
|---|
| 1287 | | - size = (y_ubwc_plane + uv_ubwc_plane + y_meta_plane + |
|---|
| 1288 | | - uv_meta_plane)*2 + |
|---|
| 1289 | | - MSM_MEDIA_MAX(extra_size + 8192, 48 * y_stride); |
|---|
| 1290 | | - size = MSM_MEDIA_ALIGN(size, 4096); |
|---|
| 1291 | | - break; |
|---|
| 1292 | | - case COLOR_FMT_NV12_BPP10_UBWC: |
|---|
| 1293 | | - y_ubwc_plane = MSM_MEDIA_ALIGN(y_stride * y_sclines, 4096); |
|---|
| 1294 | | - uv_ubwc_plane = MSM_MEDIA_ALIGN(uv_stride * uv_sclines, 4096); |
|---|
| 1295 | | - y_meta_stride = VENUS_Y_META_STRIDE(color_fmt, width); |
|---|
| 1296 | | - y_meta_scanlines = VENUS_Y_META_SCANLINES(color_fmt, height); |
|---|
| 1297 | | - y_meta_plane = MSM_MEDIA_ALIGN( |
|---|
| 1298 | | - y_meta_stride * y_meta_scanlines, 4096); |
|---|
| 1299 | | - uv_meta_stride = VENUS_UV_META_STRIDE(color_fmt, width); |
|---|
| 1300 | | - uv_meta_scanlines = VENUS_UV_META_SCANLINES(color_fmt, height); |
|---|
| 1301 | | - uv_meta_plane = MSM_MEDIA_ALIGN(uv_meta_stride * |
|---|
| 1302 | | - uv_meta_scanlines, 4096); |
|---|
| 1303 | | - |
|---|
| 1304 | | - size = y_ubwc_plane + uv_ubwc_plane + y_meta_plane + |
|---|
| 1305 | | - uv_meta_plane + |
|---|
| 1306 | | - MSM_MEDIA_MAX(extra_size + 8192, 48 * y_stride); |
|---|
| 1307 | | - size = MSM_MEDIA_ALIGN(size, 4096); |
|---|
| 1308 | | - break; |
|---|
| 1309 | | - case COLOR_FMT_P010_UBWC: |
|---|
| 1310 | | - y_ubwc_plane = MSM_MEDIA_ALIGN(y_stride * y_sclines, 4096); |
|---|
| 1311 | | - uv_ubwc_plane = MSM_MEDIA_ALIGN(uv_stride * uv_sclines, 4096); |
|---|
| 1312 | | - y_meta_stride = VENUS_Y_META_STRIDE(color_fmt, width); |
|---|
| 1313 | | - y_meta_scanlines = VENUS_Y_META_SCANLINES(color_fmt, height); |
|---|
| 1314 | | - y_meta_plane = MSM_MEDIA_ALIGN( |
|---|
| 1315 | | - y_meta_stride * y_meta_scanlines, 4096); |
|---|
| 1316 | | - uv_meta_stride = VENUS_UV_META_STRIDE(color_fmt, width); |
|---|
| 1317 | | - uv_meta_scanlines = VENUS_UV_META_SCANLINES(color_fmt, height); |
|---|
| 1318 | | - uv_meta_plane = MSM_MEDIA_ALIGN(uv_meta_stride * |
|---|
| 1319 | | - uv_meta_scanlines, 4096); |
|---|
| 1320 | | - |
|---|
| 1321 | | - size = y_ubwc_plane + uv_ubwc_plane + y_meta_plane + |
|---|
| 1322 | | - uv_meta_plane; |
|---|
| 1323 | | - size = MSM_MEDIA_ALIGN(size, 4096); |
|---|
| 1324 | | - break; |
|---|
| 1325 | | - case COLOR_FMT_RGBA8888: |
|---|
| 1326 | | - rgb_plane = MSM_MEDIA_ALIGN(rgb_stride * rgb_scanlines, 4096); |
|---|
| 1327 | | - size = rgb_plane; |
|---|
| 1328 | | - size = MSM_MEDIA_ALIGN(size, 4096); |
|---|
| 1329 | | - break; |
|---|
| 1330 | | - case COLOR_FMT_RGBA8888_UBWC: |
|---|
| 1331 | | - case COLOR_FMT_RGBA1010102_UBWC: |
|---|
| 1332 | | - case COLOR_FMT_RGB565_UBWC: |
|---|
| 1333 | | - rgb_ubwc_plane = MSM_MEDIA_ALIGN(rgb_stride * rgb_scanlines, |
|---|
| 1334 | | - 4096); |
|---|
| 1335 | | - rgb_meta_stride = VENUS_RGB_META_STRIDE(color_fmt, width); |
|---|
| 1336 | | - rgb_meta_scanlines = VENUS_RGB_META_SCANLINES(color_fmt, |
|---|
| 1337 | | - height); |
|---|
| 1338 | | - rgb_meta_plane = MSM_MEDIA_ALIGN(rgb_meta_stride * |
|---|
| 1339 | | - rgb_meta_scanlines, 4096); |
|---|
| 1340 | | - size = rgb_ubwc_plane + rgb_meta_plane; |
|---|
| 1341 | | - size = MSM_MEDIA_ALIGN(size, 4096); |
|---|
| 1342 | | - break; |
|---|
| 1343 | | - default: |
|---|
| 1344 | | - break; |
|---|
| 1345 | | - } |
|---|
| 1346 | | -invalid_input: |
|---|
| 1347 | | - return size; |
|---|
| 1348 | | -} |
|---|
| 1349 | | - |
|---|
| 1350 | | -static inline unsigned int VENUS_VIEW2_OFFSET( |
|---|
| 1351 | | - int color_fmt, int width, int height) |
|---|
| 1352 | | -{ |
|---|
| 1353 | | - unsigned int offset = 0; |
|---|
| 1354 | | - unsigned int y_plane, uv_plane, y_stride, |
|---|
| 1355 | | - uv_stride, y_sclines, uv_sclines; |
|---|
| 1356 | | - if (!width || !height) |
|---|
| 1357 | | - goto invalid_input; |
|---|
| 1358 | | - |
|---|
| 1359 | | - y_stride = VENUS_Y_STRIDE(color_fmt, width); |
|---|
| 1360 | | - uv_stride = VENUS_UV_STRIDE(color_fmt, width); |
|---|
| 1361 | | - y_sclines = VENUS_Y_SCANLINES(color_fmt, height); |
|---|
| 1362 | | - uv_sclines = VENUS_UV_SCANLINES(color_fmt, height); |
|---|
| 1363 | | - switch (color_fmt) { |
|---|
| 1364 | | - case COLOR_FMT_NV12_MVTB: |
|---|
| 1365 | | - y_plane = y_stride * y_sclines; |
|---|
| 1366 | | - uv_plane = uv_stride * uv_sclines; |
|---|
| 1367 | | - offset = y_plane + uv_plane; |
|---|
| 1368 | | - break; |
|---|
| 1369 | | - default: |
|---|
| 1370 | | - break; |
|---|
| 1371 | | - } |
|---|
| 1372 | | -invalid_input: |
|---|
| 1373 | | - return offset; |
|---|
| 1152 | + return 0; |
|---|
| 1374 | 1153 | } |
|---|
| 1375 | 1154 | |
|---|
| 1376 | 1155 | #endif |
|---|