linux/drivers/gpu/drm/sti/sti_hqvdp.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (C) STMicroelectronics SA 2014
 * Authors: Fabien Dessenne <[email protected]> for STMicroelectronics.
 */

#include <linux/component.h>
#include <linux/delay.h>
#include <linux/dma-mapping.h>
#include <linux/firmware.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/reset.h>
#include <linux/seq_file.h>

#include <drm/drm_atomic.h>
#include <drm/drm_device.h>
#include <drm/drm_fb_dma_helper.h>
#include <drm/drm_fourcc.h>
#include <drm/drm_framebuffer.h>
#include <drm/drm_gem_dma_helper.h>

#include "sti_compositor.h"
#include "sti_drv.h"
#include "sti_hqvdp_lut.h"
#include "sti_plane.h"
#include "sti_vtg.h"

/* Firmware name */
#define HQVDP_FMW_NAME

/* Regs address */
#define HQVDP_DMEM
#define HQVDP_PMEM
#define HQVDP_RD_PLUG
#define HQVDP_RD_PLUG_CONTROL
#define HQVDP_RD_PLUG_PAGE_SIZE
#define HQVDP_RD_PLUG_MIN_OPC
#define HQVDP_RD_PLUG_MAX_OPC
#define HQVDP_RD_PLUG_MAX_CHK
#define HQVDP_RD_PLUG_MAX_MSG
#define HQVDP_RD_PLUG_MIN_SPACE
#define HQVDP_WR_PLUG
#define HQVDP_WR_PLUG_CONTROL
#define HQVDP_WR_PLUG_PAGE_SIZE
#define HQVDP_WR_PLUG_MIN_OPC
#define HQVDP_WR_PLUG_MAX_OPC
#define HQVDP_WR_PLUG_MAX_CHK
#define HQVDP_WR_PLUG_MAX_MSG
#define HQVDP_WR_PLUG_MIN_SPACE
#define HQVDP_MBX
#define HQVDP_MBX_IRQ_TO_XP70
#define HQVDP_MBX_INFO_HOST
#define HQVDP_MBX_IRQ_TO_HOST
#define HQVDP_MBX_INFO_XP70
#define HQVDP_MBX_SW_RESET_CTRL
#define HQVDP_MBX_STARTUP_CTRL1
#define HQVDP_MBX_STARTUP_CTRL2
#define HQVDP_MBX_GP_STATUS
#define HQVDP_MBX_NEXT_CMD
#define HQVDP_MBX_CURRENT_CMD
#define HQVDP_MBX_SOFT_VSYNC

/* Plugs config */
#define PLUG_CONTROL_ENABLE
#define PLUG_PAGE_SIZE_256
#define PLUG_MIN_OPC_8
#define PLUG_MAX_OPC_64
#define PLUG_MAX_CHK_2X
#define PLUG_MAX_MSG_1X
#define PLUG_MIN_SPACE_1

/* SW reset CTRL */
#define SW_RESET_CTRL_FULL
#define SW_RESET_CTRL_CORE

/* Startup ctrl 1 */
#define STARTUP_CTRL1_RST_DONE
#define STARTUP_CTRL1_AUTH_IDLE

/* Startup ctrl 2 */
#define STARTUP_CTRL2_FETCH_EN

/* Info xP70 */
#define INFO_XP70_FW_READY
#define INFO_XP70_FW_PROCESSING
#define INFO_XP70_FW_INITQUEUES

/* SOFT_VSYNC */
#define SOFT_VSYNC_HW
#define SOFT_VSYNC_SW_CMD
#define SOFT_VSYNC_SW_CTRL_IRQ

/* Reset & boot poll config */
#define POLL_MAX_ATTEMPT
#define POLL_DELAY_MS

#define SCALE_FACTOR
#define SCALE_MAX_FOR_LEG_LUT_F
#define SCALE_MAX_FOR_LEG_LUT_E
#define SCALE_MAX_FOR_LEG_LUT_D
#define SCALE_MAX_FOR_LEG_LUT_C

enum sti_hvsrc_orient {};

/* Command structures */
struct sti_hqvdp_top {};

/* Configs for interlaced : no IT, no pass thru, 3 fields */
#define TOP_CONFIG_INTER_BTM
#define TOP_CONFIG_INTER_TOP

/* Config for progressive : no IT, no pass thru, 3 fields */
#define TOP_CONFIG_PROGRESSIVE

/* Default MemFormat: in=420_raster_dual out=444_raster;opaque Mem2Tv mode */
#define TOP_MEM_FORMAT_DFLT

/* Min/Max size */
#define MAX_WIDTH
#define MAX_HEIGHT
#define MIN_WIDTH
#define MIN_HEIGHT

struct sti_hqvdp_vc1re {};

struct sti_hqvdp_fmd {};

struct sti_hqvdp_csdi {};

/* Config for progressive: by pass */
#define CSDI_CONFIG_PROG
/* Config for directional deinterlacing without motion */
#define CSDI_CONFIG_INTER_DIR
/* Additional configs for fader, blender, motion,... deinterlace algorithms */
#define CSDI_CONFIG2_DFLT
#define CSDI_DCDI_CONFIG_DFLT

struct sti_hqvdp_hvsrc {};

/* Default ParamCtrl: all controls enabled */
#define HVSRC_PARAM_CTRL_DFLT

struct sti_hqvdp_iqi {};

/* Default Config : IQI bypassed */
#define IQI_CONFIG_DFLT
/* Default Contrast & Brightness gain = 256 */
#define IQI_CON_BRI_DFLT
/* Default Saturation gain = 256 */
#define IQI_SAT_GAIN_DFLT
/* Default PxfConf : P2I bypassed */
#define IQI_PXF_CONF_DFLT

struct sti_hqvdp_top_status {};

struct sti_hqvdp_fmd_status {};

struct sti_hqvdp_csdi_status {};

struct sti_hqvdp_hvsrc_status {};

struct sti_hqvdp_iqi_status {};

/* Main commands. We use 2 commands one being processed by the firmware, one
 * ready to be fetched upon next Vsync*/
#define NB_VDP_CMD

struct sti_hqvdp_cmd {};

/*
 * STI HQVDP structure
 *
 * @dev:               driver device
 * @drm_dev:           the drm device
 * @regs:              registers
 * @plane:             plane structure for hqvdp it self
 * @clk:               IP clock
 * @clk_pix_main:      pix main clock
 * @reset:             reset control
 * @vtg_nb:            notifier to handle VTG Vsync
 * @btm_field_pending: is there any bottom field (interlaced frame) to display
 * @hqvdp_cmd:         buffer of commands
 * @hqvdp_cmd_paddr:   physical address of hqvdp_cmd
 * @vtg:               vtg for main data path
 * @xp70_initialized:  true if xp70 is already initialized
 * @vtg_registered:    true if registered to VTG
 */
struct sti_hqvdp {};

#define to_sti_hqvdp(x)

static const uint32_t hqvdp_supported_formats[] =;

/**
 * sti_hqvdp_get_free_cmd
 * @hqvdp: hqvdp structure
 *
 * Look for a hqvdp_cmd that is not being used (or about to be used) by the FW.
 *
 * RETURNS:
 * the offset of the command to be used.
 * -1 in error cases
 */
static int sti_hqvdp_get_free_cmd(struct sti_hqvdp *hqvdp)
{}

/**
 * sti_hqvdp_get_curr_cmd
 * @hqvdp: hqvdp structure
 *
 * Look for the hqvdp_cmd that is being used by the FW.
 *
 * RETURNS:
 *  the offset of the command to be used.
 * -1 in error cases
 */
static int sti_hqvdp_get_curr_cmd(struct sti_hqvdp *hqvdp)
{}

/**
 * sti_hqvdp_get_next_cmd
 * @hqvdp: hqvdp structure
 *
 * Look for the next hqvdp_cmd that will be used by the FW.
 *
 * RETURNS:
 *  the offset of the next command that will be used.
 * -1 in error cases
 */
static int sti_hqvdp_get_next_cmd(struct sti_hqvdp *hqvdp)
{}

#define DBGFS_DUMP(reg)

static const char *hqvdp_dbg_get_lut(u32 *coef)
{}

static void hqvdp_dbg_dump_cmd(struct seq_file *s, struct sti_hqvdp_cmd *c)
{}

static int hqvdp_dbg_show(struct seq_file *s, void *data)
{}

static struct drm_info_list hqvdp_debugfs_files[] =;

static void hqvdp_debugfs_init(struct sti_hqvdp *hqvdp, struct drm_minor *minor)
{}

/**
 * sti_hqvdp_update_hvsrc
 * @orient: horizontal or vertical
 * @scale:  scaling/zoom factor
 * @hvsrc:  the structure containing the LUT coef
 *
 * Update the Y and C Lut coef, as well as the shift param
 *
 * RETURNS:
 * None.
 */
static void sti_hqvdp_update_hvsrc(enum sti_hvsrc_orient orient, int scale,
		struct sti_hqvdp_hvsrc *hvsrc)
{}

/**
 * sti_hqvdp_check_hw_scaling
 * @hqvdp: hqvdp pointer
 * @mode: display mode with timing constraints
 * @src_w: source width
 * @src_h: source height
 * @dst_w: destination width
 * @dst_h: destination height
 *
 * Check if the HW is able to perform the scaling request
 * The firmware scaling limitation is "CEIL(1/Zy) <= FLOOR(LFW)" where:
 *   Zy = OutputHeight / InputHeight
 *   LFW = (Tx * IPClock) / (MaxNbCycles * Cp)
 *     Tx : Total video mode horizontal resolution
 *     IPClock : HQVDP IP clock (Mhz)
 *     MaxNbCycles: max(InputWidth, OutputWidth)
 *     Cp: Video mode pixel clock (Mhz)
 *
 * RETURNS:
 * True if the HW can scale.
 */
static bool sti_hqvdp_check_hw_scaling(struct sti_hqvdp *hqvdp,
				       struct drm_display_mode *mode,
				       int src_w, int src_h,
				       int dst_w, int dst_h)
{}

/**
 * sti_hqvdp_disable
 * @hqvdp: hqvdp pointer
 *
 * Disables the HQVDP plane
 */
static void sti_hqvdp_disable(struct sti_hqvdp *hqvdp)
{}

/**
 * sti_hqvdp_vtg_cb
 * @nb: notifier block
 * @evt: event message
 * @data: private data
 *
 * Handle VTG Vsync event, display pending bottom field
 *
 * RETURNS:
 * 0 on success.
 */
static int sti_hqvdp_vtg_cb(struct notifier_block *nb, unsigned long evt, void *data)
{}

static void sti_hqvdp_init(struct sti_hqvdp *hqvdp)
{}

static void sti_hqvdp_init_plugs(struct sti_hqvdp *hqvdp)
{}

/**
 * sti_hqvdp_start_xp70
 * @hqvdp: hqvdp pointer
 *
 * Run the xP70 initialization sequence
 */
static void sti_hqvdp_start_xp70(struct sti_hqvdp *hqvdp)
{}

static int sti_hqvdp_atomic_check(struct drm_plane *drm_plane,
				  struct drm_atomic_state *state)
{}

static void sti_hqvdp_atomic_update(struct drm_plane *drm_plane,
				    struct drm_atomic_state *state)
{}

static void sti_hqvdp_atomic_disable(struct drm_plane *drm_plane,
				     struct drm_atomic_state *state)
{}

static const struct drm_plane_helper_funcs sti_hqvdp_helpers_funcs =;

static int sti_hqvdp_late_register(struct drm_plane *drm_plane)
{}

static const struct drm_plane_funcs sti_hqvdp_plane_helpers_funcs =;

static struct drm_plane *sti_hqvdp_create(struct drm_device *drm_dev,
					  struct device *dev, int desc)
{}

static int sti_hqvdp_bind(struct device *dev, struct device *master, void *data)
{}

static void sti_hqvdp_unbind(struct device *dev,
		struct device *master, void *data)
{}

static const struct component_ops sti_hqvdp_ops =;

static int sti_hqvdp_probe(struct platform_device *pdev)
{}

static void sti_hqvdp_remove(struct platform_device *pdev)
{}

static const struct of_device_id hqvdp_of_match[] =;
MODULE_DEVICE_TABLE(of, hqvdp_of_match);

struct platform_driver sti_hqvdp_driver =;

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();