linux/drivers/video/fbdev/aty/aty128fb.c

// SPDX-License-Identifier: GPL-2.0-only
/* $Id: aty128fb.c,v 1.1.1.1.36.1 1999/12/11 09:03:05 Exp $
 *  linux/drivers/video/aty128fb.c -- Frame buffer device for ATI Rage128
 *
 *  Copyright (C) 1999-2003, Brad Douglas <[email protected]>
 *  Copyright (C) 1999, Anthony Tong <[email protected]>
 *
 *                Ani Joshi / Jeff Garzik
 *                      - Code cleanup
 *
 *                Michel Danzer <[email protected]>
 *                      - 15/16 bit cleanup
 *                      - fix panning
 *
 *                Benjamin Herrenschmidt
 *                      - pmac-specific PM stuff
 *			- various fixes & cleanups
 *
 *                Andreas Hundt <[email protected]>
 *                      - FB_ACTIVATE fixes
 *
 *		  Paul Mackerras <[email protected]>
 *			- Convert to new framebuffer API,
 *			  fix colormap setting at 16 bits/pixel (565)
 *
 *		  Paul Mundt
 *		  	- PCI hotplug
 *
 *		  Jon Smirl <[email protected]>
 * 			- PCI ID update
 * 			- replace ROM BIOS search
 *
 *  Based off of Geert's atyfb.c and vfb.c.
 *
 *  TODO:
 *		- monitor sensing (DDC)
 *              - virtual display
 *		- other platform support (only ppc/x86 supported)
 *		- hardware cursor support
 *
 *    Please cc: your patches to [email protected].
 */

/*
 * A special note of gratitude to ATI's devrel for providing documentation,
 * example code and hardware. Thanks Nitya.	-atong and brad
 */


#include <linux/aperture.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/string.h>
#include <linux/mm.h>
#include <linux/vmalloc.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/uaccess.h>
#include <linux/fb.h>
#include <linux/init.h>
#include <linux/pci.h>
#include <linux/ioport.h>
#include <linux/console.h>
#include <linux/backlight.h>
#include <asm/io.h>

#ifdef CONFIG_PPC_PMAC
#include <asm/machdep.h>
#include <asm/pmac_feature.h>
#include "../macmodes.h"
#endif

#ifdef CONFIG_PMAC_BACKLIGHT
#include <asm/backlight.h>
#endif

#ifdef CONFIG_BOOTX_TEXT
#include <asm/btext.h>
#endif /* CONFIG_BOOTX_TEXT */

#include <video/aty128.h>

/* Debug flag */
#undef DEBUG

#ifdef DEBUG
#define DBG
#else
#define DBG(fmt, args...)
#endif

#ifndef CONFIG_PPC_PMAC
/* default mode */
static const struct fb_var_screeninfo default_var =;

#else /* CONFIG_PPC_PMAC */
/* default to 1024x768 at 75Hz on PPC - this will work
 * on the iMac, the usual 640x480 @ 60Hz doesn't. */
static const struct fb_var_screeninfo default_var = {
	/* 1024x768, 75 Hz, Non-Interlaced (78.75 MHz dotclock) */
	1024, 768, 1024, 768, 0, 0, 8, 0,
	{0, 8, 0}, {0, 8, 0}, {0, 8, 0}, {0, 0, 0},
	0, 0, -1, -1, 0, 12699, 160, 32, 28, 1, 96, 3,
	FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
	FB_VMODE_NONINTERLACED
};
#endif /* CONFIG_PPC_PMAC */

/* default modedb mode */
/* 640x480, 60 Hz, Non-Interlaced (25.172 MHz dotclock) */
static const struct fb_videomode defaultmode =;

/* Chip generations */
enum {};

/* Must match above enum */
static char * const r128_family[] =;

/*
 * PCI driver prototypes
 */
static int aty128_probe(struct pci_dev *pdev,
                               const struct pci_device_id *ent);
static void aty128_remove(struct pci_dev *pdev);
static int aty128_pci_suspend_late(struct device *dev, pm_message_t state);
static int __maybe_unused aty128_pci_suspend(struct device *dev);
static int __maybe_unused aty128_pci_hibernate(struct device *dev);
static int __maybe_unused aty128_pci_freeze(struct device *dev);
static int __maybe_unused aty128_pci_resume(struct device *dev);
static int aty128_do_resume(struct pci_dev *pdev);

static const struct dev_pm_ops aty128_pci_pm_ops =;

/* supported Rage128 chipsets */
static const struct pci_device_id aty128_pci_tbl[] =;

MODULE_DEVICE_TABLE(pci, aty128_pci_tbl);

static struct pci_driver aty128fb_driver =;

/* packed BIOS settings */
#ifndef CONFIG_PPC
PLL_BLOCK;
#endif /* !CONFIG_PPC */

/* onboard memory information */
struct aty128_meminfo {};

/* various memory configurations */
static const struct aty128_meminfo sdr_128 =;

static const struct aty128_meminfo sdr_sgram =;

static const struct aty128_meminfo ddr_sgram =;

static const struct fb_fix_screeninfo aty128fb_fix =;

static char *mode_option =;

#ifdef CONFIG_PPC_PMAC
static int default_vmode = VMODE_1024_768_60;
static int default_cmode = CMODE_8;
#endif

static int default_crt_on =;
static int default_lcd_on =;
static bool mtrr =;

#ifdef CONFIG_FB_ATY128_BACKLIGHT
static int backlight = IS_BUILTIN();
#endif

/* PLL constants */
struct aty128_constants {};

struct aty128_crtc {};

struct aty128_pll {};

struct aty128_ddafifo {};

/* register values for a specific mode */
struct aty128fb_par {};


#define round_div(n, d)

static int aty128fb_check_var(struct fb_var_screeninfo *var,
			      struct fb_info *info);
static int aty128fb_set_par(struct fb_info *info);
static int aty128fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
			      u_int transp, struct fb_info *info);
static int aty128fb_pan_display(struct fb_var_screeninfo *var,
			   struct fb_info *fb);
static int aty128fb_blank(int blank, struct fb_info *fb);
static int aty128fb_ioctl(struct fb_info *info, u_int cmd, unsigned long arg);
static int aty128fb_sync(struct fb_info *info);

    /*
     *  Internal routines
     */

static int aty128_encode_var(struct fb_var_screeninfo *var,
                             const struct aty128fb_par *par);
static int aty128_decode_var(struct fb_var_screeninfo *var,
                             struct aty128fb_par *par);
static void aty128_timings(struct aty128fb_par *par);
static void aty128_init_engine(struct aty128fb_par *par);
static void aty128_reset_engine(const struct aty128fb_par *par);
static void aty128_flush_pixel_cache(const struct aty128fb_par *par);
static void do_wait_for_fifo(u16 entries, struct aty128fb_par *par);
static void wait_for_fifo(u16 entries, struct aty128fb_par *par);
static void wait_for_idle(struct aty128fb_par *par);
static u32 depth_to_dst(u32 depth);

#ifdef CONFIG_FB_ATY128_BACKLIGHT
static void aty128_bl_set_power(struct fb_info *info, int power);
#endif

#define BIOS_IN8(v)
#define BIOS_IN16(v)
#define BIOS_IN32(v)


static const struct fb_ops aty128fb_ops =;

    /*
     * Functions to read from/write to the mmio registers
     *	- endian conversions may possibly be avoided by
     *    using the other register aperture. TODO.
     */
static inline u32 _aty_ld_le32(volatile unsigned int regindex,
			       const struct aty128fb_par *par)
{}

static inline void _aty_st_le32(volatile unsigned int regindex, u32 val,
				const struct aty128fb_par *par)
{}

static inline u8 _aty_ld_8(unsigned int regindex,
			   const struct aty128fb_par *par)
{}

static inline void _aty_st_8(unsigned int regindex, u8 val,
			     const struct aty128fb_par *par)
{}

#define aty_ld_le32(regindex)
#define aty_st_le32(regindex, val)
#define aty_ld_8(regindex)
#define aty_st_8(regindex, val)

    /*
     * Functions to read from/write to the pll registers
     */

#define aty_ld_pll(pll_index)
#define aty_st_pll(pll_index, val)


static u32 _aty_ld_pll(unsigned int pll_index,
		       const struct aty128fb_par *par)
{}


static void _aty_st_pll(unsigned int pll_index, u32 val,
			const struct aty128fb_par *par)
{}


/* return true when the PLL has completed an atomic update */
static int aty_pll_readupdate(const struct aty128fb_par *par)
{}


static void aty_pll_wait_readupdate(const struct aty128fb_par *par)
{}


/* tell PLL to update */
static void aty_pll_writeupdate(const struct aty128fb_par *par)
{}


/* write to the scratch register to test r/w functionality */
static int register_test(const struct aty128fb_par *par)
{}


/*
 * Accelerator engine functions
 */
static void do_wait_for_fifo(u16 entries, struct aty128fb_par *par)
{}


static void wait_for_idle(struct aty128fb_par *par)
{}


static void wait_for_fifo(u16 entries, struct aty128fb_par *par)
{}


static void aty128_flush_pixel_cache(const struct aty128fb_par *par)
{}


static void aty128_reset_engine(const struct aty128fb_par *par)
{}


static void aty128_init_engine(struct aty128fb_par *par)
{}


/* convert depth values to their register representation */
static u32 depth_to_dst(u32 depth)
{}

/*
 * PLL informations retreival
 */


#ifndef __sparc__
static void __iomem *aty128_map_ROM(const struct aty128fb_par *par,
				    struct pci_dev *dev)
{}

static void aty128_get_pllinfo(struct aty128fb_par *par,
			       unsigned char __iomem *bios)
{}

#ifdef CONFIG_X86
static void __iomem *aty128_find_mem_vbios(struct aty128fb_par *par)
{}
#endif
#endif /* ndef(__sparc__) */

/* fill in known card constants if pll_block is not available */
static void aty128_timings(struct aty128fb_par *par)
{}



/*
 * CRTC programming
 */

/* Program the CRTC registers */
static void aty128_set_crtc(const struct aty128_crtc *crtc,
			    const struct aty128fb_par *par)
{}


static int aty128_var_to_crtc(const struct fb_var_screeninfo *var,
			      struct aty128_crtc *crtc,
			      const struct aty128fb_par *par)
{}


static int aty128_pix_width_to_var(int pix_width, struct fb_var_screeninfo *var)
{}


static int aty128_crtc_to_var(const struct aty128_crtc *crtc,
			      struct fb_var_screeninfo *var)
{}

static void aty128_set_crt_enable(struct aty128fb_par *par, int on)
{}

static void aty128_set_lcd_enable(struct aty128fb_par *par, int on)
{}

static void aty128_set_pll(struct aty128_pll *pll,
			   const struct aty128fb_par *par)
{}


static int aty128_var_to_pll(u32 period_in_ps, struct aty128_pll *pll,
			     const struct aty128fb_par *par)
{}


static int aty128_pll_to_var(const struct aty128_pll *pll,
			     struct fb_var_screeninfo *var)
{}


static void aty128_set_fifo(const struct aty128_ddafifo *dsp,
			    const struct aty128fb_par *par)
{}


static int aty128_ddafifo(struct aty128_ddafifo *dsp,
			  const struct aty128_pll *pll,
			  u32 depth,
			  const struct aty128fb_par *par)
{}


/*
 * This actually sets the video mode.
 */
static int aty128fb_set_par(struct fb_info *info)
{}

/*
 *  encode/decode the User Defined Part of the Display
 */

static int aty128_decode_var(struct fb_var_screeninfo *var,
			     struct aty128fb_par *par)
{}


static int aty128_encode_var(struct fb_var_screeninfo *var,
			     const struct aty128fb_par *par)
{}


static int aty128fb_check_var(struct fb_var_screeninfo *var,
			      struct fb_info *info)
{}


/*
 *  Pan or Wrap the Display
 */
static int aty128fb_pan_display(struct fb_var_screeninfo *var,
				struct fb_info *fb)
{}


/*
 *  Helper function to store a single palette register
 */
static void aty128_st_pal(u_int regno, u_int red, u_int green, u_int blue,
			  struct aty128fb_par *par)
{}

static int aty128fb_sync(struct fb_info *info)
{}

#ifndef MODULE
static int aty128fb_setup(char *options)
{}
#endif  /*  MODULE  */

/* Backlight */
#ifdef CONFIG_FB_ATY128_BACKLIGHT
#define MAX_LEVEL

static int aty128_bl_get_level_brightness(struct aty128fb_par *par,
		int level)
{}

/* We turn off the LCD completely instead of just dimming the backlight.
 * This provides greater power saving and the display is useless without
 * backlight anyway
 */
#define BACKLIGHT_LVDS_OFF
/* That one prevents proper CRT output with LCD off */
#undef BACKLIGHT_DAC_OFF

static int aty128_bl_update_status(struct backlight_device *bd)
{}

static const struct backlight_ops aty128_bl_data =;

static void aty128_bl_set_power(struct fb_info *info, int power)
{}

static void aty128_bl_init(struct aty128fb_par *par)
{}

static void aty128_bl_exit(struct backlight_device *bd)
{}
#endif /* CONFIG_FB_ATY128_BACKLIGHT */

/*
 *  Initialisation
 */

#ifdef CONFIG_PPC_PMAC__disabled
static void aty128_early_resume(void *data)
{
        struct aty128fb_par *par = data;

	if (!console_trylock())
		return;
	pci_restore_state(par->pdev);
	aty128_do_resume(par->pdev);
	console_unlock();
}
#endif /* CONFIG_PPC_PMAC */

static int aty128_init(struct pci_dev *pdev, const struct pci_device_id *ent)
{}

#ifdef CONFIG_PCI
/* register a card    ++ajoshi */
static int aty128_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{}

static void aty128_remove(struct pci_dev *pdev)
{}
#endif /* CONFIG_PCI */



    /*
     *  Blank the display.
     */
static int aty128fb_blank(int blank, struct fb_info *fb)
{}

/*
 *  Set a single color register. The values supplied are already
 *  rounded down to the hardware's capabilities (according to the
 *  entries in the var structure). Return != 0 for invalid regno.
 */
static int aty128fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
			      u_int transp, struct fb_info *info)
{}

#define ATY_MIRROR_LCD_ON
#define ATY_MIRROR_CRT_ON

/* out param: u32*	backlight value: 0 to 15 */
#define FBIO_ATY128_GET_MIRROR
/* in param: u32*	backlight value: 0 to 15 */
#define FBIO_ATY128_SET_MIRROR

static int aty128fb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
{}

static void aty128_set_suspend(struct aty128fb_par *par, int suspend)
{}

static int aty128_pci_suspend_late(struct device *dev, pm_message_t state)
{}

static int __maybe_unused aty128_pci_suspend(struct device *dev)
{}

static int __maybe_unused aty128_pci_hibernate(struct device *dev)
{}

static int __maybe_unused aty128_pci_freeze(struct device *dev)
{}

static int aty128_do_resume(struct pci_dev *pdev)
{}

static int __maybe_unused aty128_pci_resume(struct device *dev)
{}


static int aty128fb_init(void)
{}

static void __exit aty128fb_exit(void)
{}

module_init();

module_exit(aty128fb_exit);

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();
module_param(mode_option, charp, 0);
MODULE_PARM_DESC();
module_param_named(nomtrr, mtrr, invbool, 0);
MODULE_PARM_DESC();