Commit f3b7e17c authored by Dave Airlie's avatar Dave Airlie

Merge branch 'topic/vga-switcheroo' of...

Merge branch 'topic/vga-switcheroo' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound into drm-core-next

* 'topic/vga-switcheroo' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound:
  vga_switcheroo: Add the support for audio clients
  vga_switcheroo: Introduce struct vga_switcheroo_client_ops
  vga_switcheroo: Refactor using linked list
parents a366e392 3e9e63db
...@@ -1271,6 +1271,12 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev) ...@@ -1271,6 +1271,12 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
return can_switch; return can_switch;
} }
static const struct vga_switcheroo_client_ops i915_switcheroo_ops = {
.set_gpu_state = i915_switcheroo_set_state,
.reprobe = NULL,
.can_switch = i915_switcheroo_can_switch,
};
static int i915_load_modeset_init(struct drm_device *dev) static int i915_load_modeset_init(struct drm_device *dev)
{ {
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
...@@ -1293,10 +1299,7 @@ static int i915_load_modeset_init(struct drm_device *dev) ...@@ -1293,10 +1299,7 @@ static int i915_load_modeset_init(struct drm_device *dev)
intel_register_dsm_handler(); intel_register_dsm_handler();
ret = vga_switcheroo_register_client(dev->pdev, ret = vga_switcheroo_register_client(dev->pdev, &i915_switcheroo_ops);
i915_switcheroo_set_state,
NULL,
i915_switcheroo_can_switch);
if (ret) if (ret)
goto cleanup_vga_client; goto cleanup_vga_client;
......
...@@ -662,6 +662,12 @@ nouveau_card_channel_init(struct drm_device *dev) ...@@ -662,6 +662,12 @@ nouveau_card_channel_init(struct drm_device *dev)
return ret; return ret;
} }
static const struct vga_switcheroo_client_ops nouveau_switcheroo_ops = {
.set_gpu_state = nouveau_switcheroo_set_state,
.reprobe = nouveau_switcheroo_reprobe,
.can_switch = nouveau_switcheroo_can_switch,
};
int int
nouveau_card_init(struct drm_device *dev) nouveau_card_init(struct drm_device *dev)
{ {
...@@ -670,9 +676,7 @@ nouveau_card_init(struct drm_device *dev) ...@@ -670,9 +676,7 @@ nouveau_card_init(struct drm_device *dev)
int ret, e = 0; int ret, e = 0;
vga_client_register(dev->pdev, dev, NULL, nouveau_vga_set_decode); vga_client_register(dev->pdev, dev, NULL, nouveau_vga_set_decode);
vga_switcheroo_register_client(dev->pdev, nouveau_switcheroo_set_state, vga_switcheroo_register_client(dev->pdev, &nouveau_switcheroo_ops);
nouveau_switcheroo_reprobe,
nouveau_switcheroo_can_switch);
/* Initialise internal driver API hooks */ /* Initialise internal driver API hooks */
ret = nouveau_init_engine_ptrs(dev); ret = nouveau_init_engine_ptrs(dev);
......
...@@ -697,6 +697,11 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev) ...@@ -697,6 +697,11 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
return can_switch; return can_switch;
} }
static const struct vga_switcheroo_client_ops radeon_switcheroo_ops = {
.set_gpu_state = radeon_switcheroo_set_state,
.reprobe = NULL,
.can_switch = radeon_switcheroo_can_switch,
};
int radeon_device_init(struct radeon_device *rdev, int radeon_device_init(struct radeon_device *rdev,
struct drm_device *ddev, struct drm_device *ddev,
...@@ -809,10 +814,7 @@ int radeon_device_init(struct radeon_device *rdev, ...@@ -809,10 +814,7 @@ int radeon_device_init(struct radeon_device *rdev,
/* this will fail for cards that aren't VGA class devices, just /* this will fail for cards that aren't VGA class devices, just
* ignore it */ * ignore it */
vga_client_register(rdev->pdev, rdev, NULL, radeon_vga_set_decode); vga_client_register(rdev->pdev, rdev, NULL, radeon_vga_set_decode);
vga_switcheroo_register_client(rdev->pdev, vga_switcheroo_register_client(rdev->pdev, &radeon_switcheroo_ops);
radeon_switcheroo_set_state,
NULL,
radeon_switcheroo_can_switch);
r = radeon_init(rdev); r = radeon_init(rdev);
if (r) if (r)
......
This diff is collapsed.
...@@ -28,13 +28,19 @@ struct vga_switcheroo_handler { ...@@ -28,13 +28,19 @@ struct vga_switcheroo_handler {
int (*get_client_id)(struct pci_dev *pdev); int (*get_client_id)(struct pci_dev *pdev);
}; };
struct vga_switcheroo_client_ops {
void (*set_gpu_state)(struct pci_dev *dev, enum vga_switcheroo_state);
void (*reprobe)(struct pci_dev *dev);
bool (*can_switch)(struct pci_dev *dev);
};
#if defined(CONFIG_VGA_SWITCHEROO) #if defined(CONFIG_VGA_SWITCHEROO)
void vga_switcheroo_unregister_client(struct pci_dev *dev); void vga_switcheroo_unregister_client(struct pci_dev *dev);
int vga_switcheroo_register_client(struct pci_dev *dev, int vga_switcheroo_register_client(struct pci_dev *dev,
void (*set_gpu_state)(struct pci_dev *dev, enum vga_switcheroo_state), const struct vga_switcheroo_client_ops *ops);
void (*reprobe)(struct pci_dev *dev), int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
bool (*can_switch)(struct pci_dev *dev)); const struct vga_switcheroo_client_ops *ops,
int id, bool active);
void vga_switcheroo_client_fb_set(struct pci_dev *dev, void vga_switcheroo_client_fb_set(struct pci_dev *dev,
struct fb_info *info); struct fb_info *info);
...@@ -48,11 +54,12 @@ int vga_switcheroo_process_delayed_switch(void); ...@@ -48,11 +54,12 @@ int vga_switcheroo_process_delayed_switch(void);
static inline void vga_switcheroo_unregister_client(struct pci_dev *dev) {} static inline void vga_switcheroo_unregister_client(struct pci_dev *dev) {}
static inline int vga_switcheroo_register_client(struct pci_dev *dev, static inline int vga_switcheroo_register_client(struct pci_dev *dev,
void (*set_gpu_state)(struct pci_dev *dev, enum vga_switcheroo_state), const struct vga_switcheroo_client_ops *ops) { return 0; }
void (*reprobe)(struct pci_dev *dev),
bool (*can_switch)(struct pci_dev *dev)) { return 0; }
static inline void vga_switcheroo_client_fb_set(struct pci_dev *dev, struct fb_info *info) {} static inline void vga_switcheroo_client_fb_set(struct pci_dev *dev, struct fb_info *info) {}
static inline int vga_switcheroo_register_handler(struct vga_switcheroo_handler *handler) { return 0; } static inline int vga_switcheroo_register_handler(struct vga_switcheroo_handler *handler) { return 0; }
static inline int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
const struct vga_switcheroo_client_ops *ops,
int id, bool active) { return 0; }
static inline void vga_switcheroo_unregister_handler(void) {} static inline void vga_switcheroo_unregister_handler(void) {}
static inline int vga_switcheroo_process_delayed_switch(void) { return 0; } static inline int vga_switcheroo_process_delayed_switch(void) { return 0; }
......
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