Commit b9a577a4 authored by Thomas Zimmermann's avatar Thomas Zimmermann

drm/mgag200: Add struct mgag200_device_info

While currently empty, struct mgag200_device_info, will provide static,
constant information on each device model.
Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: default avatarJocelyn Falempe <jfalempe@redhat.com>
Tested-by: default avatarJocelyn Falempe <jfalempe@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220601112522.5774-7-tzimmermann@suse.de
parent b62d943e
......@@ -162,13 +162,15 @@ int mgag200_device_preinit(struct mga_device *mdev)
return 0;
}
int mgag200_device_init(struct mga_device *mdev, enum mga_type type, unsigned long flags)
int mgag200_device_init(struct mga_device *mdev, enum mga_type type, unsigned long flags,
const struct mgag200_device_info *info)
{
struct drm_device *dev = &mdev->base;
u8 crtcext3, misc;
int ret;
mdev->flags = flags;
mdev->info = info;
mdev->type = type;
ret = drmm_mutex_init(dev, &mdev->rmmio_lock);
......
......@@ -196,10 +196,19 @@ enum mga_type {
#define IS_G200_SE(mdev) (mdev->type == G200_SE_A || mdev->type == G200_SE_B)
struct mgag200_device_info {
};
#define MGAG200_DEVICE_INFO_INIT() \
{ \
}
struct mga_device {
struct drm_device base;
unsigned long flags;
const struct mgag200_device_info *info;
struct resource *rmmio_res;
void __iomem *rmmio;
struct mutex rmmio_lock; /* Protects access to rmmio */
......@@ -252,7 +261,8 @@ int mgag200_init_pci_options(struct pci_dev *pdev, u32 option, u32 option2);
resource_size_t mgag200_probe_vram(void __iomem *mem, resource_size_t size);
resource_size_t mgag200_device_probe_vram(struct mga_device *mdev);
int mgag200_device_preinit(struct mga_device *mdev);
int mgag200_device_init(struct mga_device *mdev, enum mga_type type, unsigned long flags);
int mgag200_device_init(struct mga_device *mdev, enum mga_type type, unsigned long flags,
const struct mgag200_device_info *info);
/* mgag200_<device type>.c */
struct mga_device *mgag200_g200_device_create(struct pci_dev *pdev, const struct drm_driver *drv,
......
......@@ -33,6 +33,9 @@ static int mgag200_g200_init_pci_options(struct pci_dev *pdev)
* DRM Device
*/
static const struct mgag200_device_info mgag200_g200_device_info =
MGAG200_DEVICE_INFO_INIT();
static void mgag200_g200_interpret_bios(struct mgag200_g200_device *g200,
const unsigned char *bios, size_t size)
{
......@@ -183,7 +186,7 @@ struct mga_device *mgag200_g200_device_create(struct pci_dev *pdev, const struct
mgag200_g200_init_refclk(g200);
ret = mgag200_device_init(mdev, type, flags);
ret = mgag200_device_init(mdev, type, flags, &mgag200_g200_device_info);
if (ret)
return ERR_PTR(ret);
......
......@@ -10,6 +10,9 @@
* DRM device
*/
static const struct mgag200_device_info mgag200_g200eh_device_info =
MGAG200_DEVICE_INFO_INIT();
struct mga_device *mgag200_g200eh_device_create(struct pci_dev *pdev, const struct drm_driver *drv,
enum mga_type type, unsigned long flags)
{
......@@ -33,7 +36,7 @@ struct mga_device *mgag200_g200eh_device_create(struct pci_dev *pdev, const stru
if (ret)
return ERR_PTR(ret);
ret = mgag200_device_init(mdev, type, flags);
ret = mgag200_device_init(mdev, type, flags, &mgag200_g200eh_device_info);
if (ret)
return ERR_PTR(ret);
......
......@@ -10,6 +10,9 @@
* DRM device
*/
static const struct mgag200_device_info mgag200_g200eh3_device_info =
MGAG200_DEVICE_INFO_INIT();
struct mga_device *mgag200_g200eh3_device_create(struct pci_dev *pdev,
const struct drm_driver *drv,
enum mga_type type, unsigned long flags)
......@@ -34,7 +37,7 @@ struct mga_device *mgag200_g200eh3_device_create(struct pci_dev *pdev,
if (ret)
return ERR_PTR(ret);
ret = mgag200_device_init(mdev, type, flags);
ret = mgag200_device_init(mdev, type, flags, &mgag200_g200eh3_device_info);
if (ret)
return ERR_PTR(ret);
......
......@@ -10,6 +10,9 @@
* DRM device
*/
static const struct mgag200_device_info mgag200_g200er_device_info =
MGAG200_DEVICE_INFO_INIT();
struct mga_device *mgag200_g200er_device_create(struct pci_dev *pdev, const struct drm_driver *drv,
enum mga_type type, unsigned long flags)
{
......@@ -29,7 +32,7 @@ struct mga_device *mgag200_g200er_device_create(struct pci_dev *pdev, const stru
if (ret)
return ERR_PTR(ret);
ret = mgag200_device_init(mdev, type, flags);
ret = mgag200_device_init(mdev, type, flags, &mgag200_g200er_device_info);
if (ret)
return ERR_PTR(ret);
......
......@@ -10,6 +10,9 @@
* DRM device
*/
static const struct mgag200_device_info mgag200_g200ev_device_info =
MGAG200_DEVICE_INFO_INIT();
struct mga_device *mgag200_g200ev_device_create(struct pci_dev *pdev, const struct drm_driver *drv,
enum mga_type type, unsigned long flags)
{
......@@ -33,7 +36,7 @@ struct mga_device *mgag200_g200ev_device_create(struct pci_dev *pdev, const stru
if (ret)
return ERR_PTR(ret);
ret = mgag200_device_init(mdev, type, flags);
ret = mgag200_device_init(mdev, type, flags, &mgag200_g200ev_device_info);
if (ret)
return ERR_PTR(ret);
......
......@@ -10,6 +10,9 @@
* DRM device
*/
static const struct mgag200_device_info mgag200_g200ew3_device_info =
MGAG200_DEVICE_INFO_INIT();
static resource_size_t mgag200_g200ew3_device_probe_vram(struct mga_device *mdev)
{
resource_size_t vram_size = resource_size(mdev->vram_res);
......@@ -43,7 +46,7 @@ struct mga_device *mgag200_g200ew3_device_create(struct pci_dev *pdev,
if (ret)
return ERR_PTR(ret);
ret = mgag200_device_init(mdev, type, flags);
ret = mgag200_device_init(mdev, type, flags, &mgag200_g200ew3_device_info);
if (ret)
return ERR_PTR(ret);
......
......@@ -32,6 +32,9 @@ static int mgag200_g200se_init_pci_options(struct pci_dev *pdev)
* DRM device
*/
static const struct mgag200_device_info mgag200_g200se_device_info =
MGAG200_DEVICE_INFO_INIT();
static void mgag200_g200se_init_unique_id(struct mgag200_g200se_device *g200se)
{
struct mga_device *mdev = &g200se->base;
......@@ -70,7 +73,7 @@ struct mga_device *mgag200_g200se_device_create(struct pci_dev *pdev, const stru
mgag200_g200se_init_unique_id(g200se);
ret = mgag200_device_init(mdev, type, flags);
ret = mgag200_device_init(mdev, type, flags, &mgag200_g200se_device_info);
if (ret)
return ERR_PTR(ret);
......
......@@ -10,6 +10,9 @@
* DRM device
*/
static const struct mgag200_device_info mgag200_g200wb_device_info =
MGAG200_DEVICE_INFO_INIT();
struct mga_device *mgag200_g200wb_device_create(struct pci_dev *pdev, const struct drm_driver *drv,
enum mga_type type, unsigned long flags)
{
......@@ -33,7 +36,7 @@ struct mga_device *mgag200_g200wb_device_create(struct pci_dev *pdev, const stru
if (ret)
return ERR_PTR(ret);
ret = mgag200_device_init(mdev, type, flags);
ret = mgag200_device_init(mdev, type, flags, &mgag200_g200wb_device_info);
if (ret)
return ERR_PTR(ret);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment