/*
* Copyright 2016 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
#include "dce_mem_input.h"
#include "reg_helper.h"
#include "basics/conversion.h"
#define CTX \
dce_mi->base.ctx
#define REG(reg)\
dce_mi->regs->reg
#undef FN
#define FN(reg_name, field_name) \
dce_mi->shifts->field_name, dce_mi->masks->field_name
struct pte_setting {
unsigned int bpp;
unsigned int page_width;
unsigned int page_height;
unsigned char min_pte_before_flip_horiz_scan;
unsigned char min_pte_before_flip_vert_scan;
unsigned char pte_req_per_chunk;
unsigned char param_6;
unsigned char param_7;
unsigned char param_8;
};
enum mi_bits_per_pixel {
mi_bpp_8 = 0,
mi_bpp_16,
mi_bpp_32,
mi_bpp_64,
mi_bpp_count,
};
enum mi_tiling_format {
mi_tiling_linear = 0,
mi_tiling_1D,
mi_tiling_2D,
mi_tiling_count,
};
static const struct pte_setting pte_settings[mi_tiling_count][mi_bpp_count] = {
[mi_tiling_linear] = {
{ 8, 4096, 1, 8, 0, 1, 0, 0, 0},
{ 16, 2048, 1, 8, 0, 1, 0, 0, 0},
{ 32, 1024, 1, 8, 0, 1, 0, 0, 0},
{ 64, 512, 1, 8, 0, 1, 0, 0, 0}, /* new for 64bpp from HW */
},
[mi_tiling_1D] = {
{ 8, 512, 8, 1, 0, 1, 0, 0, 0}, /* 0 for invalid */
{ 16, 256, 8, 2, 0, 1, 0, 0, 0},
{ 32, 128, 8, 4, 0, 1, 0, 0, 0},
{ 64, 64, 8, 4, 0, 1, 0, 0, 0}, /* fake */
},
[mi_tiling_2D] = {
{ 8, 64, 64, 8, 8, 1, 4, 0, 0},
{ 16, 64, 32, 8, 16, 1, 8, 0, 0},
{ 32, 32, 32, 16, 16, 1, 8, 0, 0},
{ 64, 8, 32, 16, 16, 1, 8, 0, 0}, /* fake */
},
};
static enum mi_bits_per_pixel get_mi_bpp(
enum surface_pixel_format format)
{
if (format >= SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616)
return mi_bpp_64;
else if (format >= SURFACE_PIXEL_FORMAT_GRPH_ARGB8888)
return mi_bpp_32;
else if (format >= SURFACE_PIXEL_FORMAT_GRPH_ARGB1555)
return mi_bpp_16;
else
return mi_bpp_8;
}
static enum mi_tiling_format get_mi_tiling(
struct dc_tiling_info *tiling_info)
{
switch (tiling_info->gfx8.array_mode) {
case DC_ARRAY_1D_TILED_THIN1:
case DC_ARRAY_1D_TILED_THICK:
case DC_ARRAY_PRT_TILED_THIN1:
return mi_tiling_1D;
case DC_ARRAY_2D_TILED_THIN1:
case DC_ARRAY_2D_TILED_THICK:
case DC_ARRAY_2D_TILED_X_THICK:
case DC_ARRAY_PRT_2D_TILED_THIN1:
case DC_ARRAY_PRT_2D_TILED_THICK:
return mi_tiling_2D;
case DC_ARRAY_LINEAR_GENERAL:
case DC_ARRAY_LINEAR_ALLIGNED:
return mi_tiling_linear;
default:
return mi_tiling_2D;
}
}
static bool is_vert_scan(enum dc_rotation_angle rotation)
{
switch (rotation) {
case ROTATION_ANGLE_90:
case ROTATION_ANGLE_270:
return