linux/drivers/gpu/drm/loongson/lsdc_crtc.c

// SPDX-License-Identifier: GPL-2.0+
/*
 * Copyright (C) 2023 Loongson Technology Corporation Limited
 */

#include <linux/debugfs.h>
#include <linux/delay.h>

#include <drm/drm_atomic.h>
#include <drm/drm_atomic_helper.h>
#include <drm/drm_debugfs.h>
#include <drm/drm_vblank.h>

#include "lsdc_drv.h"

/*
 * After the CRTC soft reset, the vblank counter would be reset to zero.
 * But the address and other settings in the CRTC register remain the same
 * as before.
 */

static void lsdc_crtc0_soft_reset(struct lsdc_crtc *lcrtc)
{}

static void lsdc_crtc1_soft_reset(struct lsdc_crtc *lcrtc)
{}

static void lsdc_crtc0_enable(struct lsdc_crtc *lcrtc)
{}

static void lsdc_crtc0_disable(struct lsdc_crtc *lcrtc)
{}

static void lsdc_crtc1_enable(struct lsdc_crtc *lcrtc)
{}

static void lsdc_crtc1_disable(struct lsdc_crtc *lcrtc)
{}

/* All Loongson display controllers have hardware scanout position recoders */

static void lsdc_crtc0_scan_pos(struct lsdc_crtc *lcrtc, int *hpos, int *vpos)
{}

static void lsdc_crtc1_scan_pos(struct lsdc_crtc *lcrtc, int *hpos, int *vpos)
{}

static void lsdc_crtc0_enable_vblank(struct lsdc_crtc *lcrtc)
{}

static void lsdc_crtc0_disable_vblank(struct lsdc_crtc *lcrtc)
{}

static void lsdc_crtc1_enable_vblank(struct lsdc_crtc *lcrtc)
{}

static void lsdc_crtc1_disable_vblank(struct lsdc_crtc *lcrtc)
{}

static void lsdc_crtc0_flip(struct lsdc_crtc *lcrtc)
{}

static void lsdc_crtc1_flip(struct lsdc_crtc *lcrtc)
{}

/*
 * CRTC0 clone from CRTC1 or CRTC1 clone from CRTC0 using hardware logic
 * This may be useful for custom cloning (TWIN) applications. Saving the
 * bandwidth compared with the clone (mirroring) display mode provided by
 * drm core.
 */

static void lsdc_crtc0_clone(struct lsdc_crtc *lcrtc)
{}

static void lsdc_crtc1_clone(struct lsdc_crtc *lcrtc)
{}

static void lsdc_crtc0_set_mode(struct lsdc_crtc *lcrtc,
				const struct drm_display_mode *mode)
{}

static void lsdc_crtc1_set_mode(struct lsdc_crtc *lcrtc,
				const struct drm_display_mode *mode)
{}

/*
 * This is required for S3 support.
 * After resuming from suspend, LSDC_CRTCx_CFG_REG (x = 0 or 1) is filled
 * with garbage value, which causes the CRTC hang there.
 *
 * This function provides minimal settings for the affected registers.
 * This overrides the firmware's settings on startup, making the CRTC work
 * on our own, similar to the functional of GPU POST (Power On Self Test).
 * Only touch CRTC hardware-related parts.
 */

static void lsdc_crtc0_reset(struct lsdc_crtc *lcrtc)
{}

static void lsdc_crtc1_reset(struct lsdc_crtc *lcrtc)
{}

static const struct lsdc_crtc_hw_ops ls7a1000_crtc_hw_ops[2] =;

/*
 * The 32-bit hardware vblank counter has been available since LS7A2000
 * and LS2K2000. The counter increases even though the CRTC is disabled,
 * it will be reset only if the CRTC is being soft reset.
 * Those registers are also readable for ls7a1000, but its value does not
 * change.
 */

static u32 lsdc_crtc0_get_vblank_count(struct lsdc_crtc *lcrtc)
{}

static u32 lsdc_crtc1_get_vblank_count(struct lsdc_crtc *lcrtc)
{}

/*
 * The DMA step bit fields are available since LS7A2000/LS2K2000, for
 * supporting odd resolutions. But a large DMA step save the bandwidth.
 * The larger, the better. Behavior of writing those bits on LS7A1000
 * or LS2K1000 is underfined.
 */

static void lsdc_crtc0_set_dma_step(struct lsdc_crtc *lcrtc,
				    enum lsdc_dma_steps dma_step)
{}

static void lsdc_crtc1_set_dma_step(struct lsdc_crtc *lcrtc,
				    enum lsdc_dma_steps dma_step)
{}

static const struct lsdc_crtc_hw_ops ls7a2000_crtc_hw_ops[2] =;

static void lsdc_crtc_reset(struct drm_crtc *crtc)
{}

static void lsdc_crtc_atomic_destroy_state(struct drm_crtc *crtc,
					   struct drm_crtc_state *state)
{}

static struct drm_crtc_state *
lsdc_crtc_atomic_duplicate_state(struct drm_crtc *crtc)
{}

static u32 lsdc_crtc_get_vblank_counter(struct drm_crtc *crtc)
{}

static int lsdc_crtc_enable_vblank(struct drm_crtc *crtc)
{}

static void lsdc_crtc_disable_vblank(struct drm_crtc *crtc)
{}

/*
 * CRTC related debugfs
 * Primary planes and cursor planes belong to the CRTC as well.
 * For the sake of convenience, plane-related registers are also add here.
 */

#define REG_DEF(reg)

static const struct lsdc_reg32 lsdc_crtc_regs_array[2][21] =;

static int lsdc_crtc_show_regs(struct seq_file *m, void *arg)
{}

static int lsdc_crtc_show_scan_position(struct seq_file *m, void *arg)
{}

static int lsdc_crtc_show_vblank_counter(struct seq_file *m, void *arg)
{}

static int lsdc_pixpll_show_clock(struct seq_file *m, void *arg)
{}

static struct drm_info_list lsdc_crtc_debugfs_list[2][4] =;

/* operate manually */

static int lsdc_crtc_man_op_show(struct seq_file *m, void *data)
{}

static int lsdc_crtc_man_op_open(struct inode *inode, struct file *file)
{}

static ssize_t lsdc_crtc_man_op_write(struct file *file,
				      const char __user *ubuf,
				      size_t len,
				      loff_t *offp)
{}

static const struct file_operations lsdc_crtc_man_op_fops =;

static int lsdc_crtc_late_register(struct drm_crtc *crtc)
{}

static void lsdc_crtc_atomic_print_state(struct drm_printer *p,
					 const struct drm_crtc_state *state)
{}

static const struct drm_crtc_funcs ls7a1000_crtc_funcs =;

static const struct drm_crtc_funcs ls7a2000_crtc_funcs =;

static enum drm_mode_status
lsdc_crtc_mode_valid(struct drm_crtc *crtc, const struct drm_display_mode *mode)
{}

static int lsdc_pixpll_atomic_check(struct drm_crtc *crtc,
				    struct drm_crtc_state *state)
{}

static int lsdc_crtc_helper_atomic_check(struct drm_crtc *crtc,
					 struct drm_atomic_state *state)
{}

static void lsdc_crtc_mode_set_nofb(struct drm_crtc *crtc)
{}

static void lsdc_crtc_send_vblank(struct drm_crtc *crtc)
{}

static void lsdc_crtc_atomic_enable(struct drm_crtc *crtc,
				    struct drm_atomic_state *state)
{}

static void lsdc_crtc_atomic_disable(struct drm_crtc *crtc,
				     struct drm_atomic_state *state)
{}

static void lsdc_crtc_atomic_flush(struct drm_crtc *crtc,
				   struct drm_atomic_state *state)
{}

static bool lsdc_crtc_get_scanout_position(struct drm_crtc *crtc,
					   bool in_vblank_irq,
					   int *vpos,
					   int *hpos,
					   ktime_t *stime,
					   ktime_t *etime,
					   const struct drm_display_mode *mode)
{}

static const struct drm_crtc_helper_funcs lsdc_crtc_helper_funcs =;

int ls7a1000_crtc_init(struct drm_device *ddev,
		       struct drm_crtc *crtc,
		       struct drm_plane *primary,
		       struct drm_plane *cursor,
		       unsigned int index,
		       bool has_vblank)
{}

int ls7a2000_crtc_init(struct drm_device *ddev,
		       struct drm_crtc *crtc,
		       struct drm_plane *primary,
		       struct drm_plane *cursor,
		       unsigned int index,
		       bool has_vblank)
{}