Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915/audio: convert LPE audio to struct intel_display

Going forward, struct intel_display will be the main display device
structure. Convert intel_lpe_audio.[ch] to it. Do some minor checkpatch
fixes while at it.

TODO: Not sure if irq_set_chip_data(irq, dev_priv); is used.

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/f04dd028cd8869cdfb9ab9eb6aceed8ff8e7ddcd.1736345025.git.jani.nikula@intel.com
Signed-off-by: Jani Nikula <jani.nikula@intel.com>

+77 -79
+4 -10
drivers/gpu/drm/i915/display/intel_audio.c
··· 732 732 const struct drm_connector_state *conn_state) 733 733 { 734 734 struct intel_display *display = to_intel_display(encoder); 735 - struct drm_i915_private *i915 = to_i915(encoder->base.dev); 736 735 struct i915_audio_component *acomp = display->audio.component; 737 736 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); 738 737 struct intel_connector *connector = to_intel_connector(conn_state->connector); ··· 773 774 (int)port, (int)cpu_transcoder); 774 775 } 775 776 776 - intel_lpe_audio_notify(i915, cpu_transcoder, port, crtc_state->eld, 777 + intel_lpe_audio_notify(display, cpu_transcoder, port, crtc_state->eld, 777 778 crtc_state->port_clock, 778 779 intel_crtc_has_dp_encoder(crtc_state)); 779 780 } ··· 792 793 const struct drm_connector_state *old_conn_state) 793 794 { 794 795 struct intel_display *display = to_intel_display(encoder); 795 - struct drm_i915_private *i915 = to_i915(encoder->base.dev); 796 796 struct i915_audio_component *acomp = display->audio.component; 797 797 struct intel_crtc *crtc = to_intel_crtc(old_crtc_state->uapi.crtc); 798 798 struct intel_connector *connector = to_intel_connector(old_conn_state->connector); ··· 831 833 (int)port, (int)cpu_transcoder); 832 834 } 833 835 834 - intel_lpe_audio_notify(i915, cpu_transcoder, port, NULL, 0, false); 836 + intel_lpe_audio_notify(display, cpu_transcoder, port, NULL, 0, false); 835 837 } 836 838 837 839 static void intel_acomp_get_config(struct intel_encoder *encoder, ··· 1397 1399 */ 1398 1400 void intel_audio_init(struct intel_display *display) 1399 1401 { 1400 - struct drm_i915_private *i915 = to_i915(display->drm); 1401 - 1402 - if (intel_lpe_audio_init(i915) < 0) 1402 + if (intel_lpe_audio_init(display) < 0) 1403 1403 i915_audio_component_init(display); 1404 1404 } 1405 1405 ··· 1413 1417 */ 1414 1418 void intel_audio_deinit(struct intel_display *display) 1415 1419 { 1416 - struct drm_i915_private *i915 = to_i915(display->drm); 1417 - 1418 1420 if (display->audio.lpe.platdev) 1419 - intel_lpe_audio_teardown(i915); 1421 + intel_lpe_audio_teardown(display); 1420 1422 else 1421 1423 i915_audio_component_cleanup(display); 1422 1424 }
+60 -58
drivers/gpu/drm/i915/display/intel_lpe_audio.c
··· 77 77 #include "intel_lpe_audio.h" 78 78 #include "intel_pci_config.h" 79 79 80 - #define HAS_LPE_AUDIO(dev_priv) ((dev_priv)->display.audio.lpe.platdev != NULL) 80 + #define HAS_LPE_AUDIO(display) ((display)->audio.lpe.platdev) 81 81 82 82 static struct platform_device * 83 - lpe_audio_platdev_create(struct drm_i915_private *dev_priv) 83 + lpe_audio_platdev_create(struct intel_display *display) 84 84 { 85 - struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev); 85 + struct pci_dev *pdev = to_pci_dev(display->drm->dev); 86 86 struct platform_device_info pinfo = {}; 87 87 struct resource *rsc; 88 88 struct platform_device *platdev; ··· 98 98 return ERR_PTR(-ENOMEM); 99 99 } 100 100 101 - rsc[0].start = rsc[0].end = dev_priv->display.audio.lpe.irq; 101 + rsc[0].start = display->audio.lpe.irq; 102 + rsc[0].end = display->audio.lpe.irq; 102 103 rsc[0].flags = IORESOURCE_IRQ; 103 104 rsc[0].name = "hdmi-lpe-audio-irq"; 104 105 ··· 110 109 rsc[1].flags = IORESOURCE_MEM; 111 110 rsc[1].name = "hdmi-lpe-audio-mmio"; 112 111 113 - pinfo.parent = dev_priv->drm.dev; 112 + pinfo.parent = display->drm->dev; 114 113 pinfo.name = "hdmi-lpe-audio"; 115 114 pinfo.id = -1; 116 115 pinfo.res = rsc; ··· 119 118 pinfo.size_data = sizeof(*pdata); 120 119 pinfo.dma_mask = DMA_BIT_MASK(32); 121 120 122 - pdata->num_pipes = INTEL_NUM_PIPES(dev_priv); 123 - pdata->num_ports = IS_CHERRYVIEW(dev_priv) ? 3 : 2; /* B,C,D or B,C */ 121 + pdata->num_pipes = INTEL_NUM_PIPES(display); 122 + pdata->num_ports = display->platform.cherryview ? 3 : 2; /* B,C,D or B,C */ 124 123 pdata->port[0].pipe = -1; 125 124 pdata->port[1].pipe = -1; 126 125 pdata->port[2].pipe = -1; ··· 131 130 kfree(pdata); 132 131 133 132 if (IS_ERR(platdev)) { 134 - drm_err(&dev_priv->drm, 133 + drm_err(display->drm, 135 134 "Failed to allocate LPE audio platform device\n"); 136 135 return platdev; 137 136 } ··· 141 140 return platdev; 142 141 } 143 142 144 - static void lpe_audio_platdev_destroy(struct drm_i915_private *dev_priv) 143 + static void lpe_audio_platdev_destroy(struct intel_display *display) 145 144 { 146 145 /* XXX Note that platform_device_register_full() allocates a dma_mask 147 146 * and never frees it. We can't free it here as we cannot guarantee ··· 151 150 * than us fiddle with its internals. 152 151 */ 153 152 154 - platform_device_unregister(dev_priv->display.audio.lpe.platdev); 153 + platform_device_unregister(display->audio.lpe.platdev); 155 154 } 156 155 157 156 static void lpe_audio_irq_unmask(struct irq_data *d) ··· 168 167 .irq_unmask = lpe_audio_irq_unmask, 169 168 }; 170 169 171 - static int lpe_audio_irq_init(struct drm_i915_private *dev_priv) 170 + static int lpe_audio_irq_init(struct intel_display *display) 172 171 { 173 - int irq = dev_priv->display.audio.lpe.irq; 172 + struct drm_i915_private *dev_priv = to_i915(display->drm); 173 + int irq = display->audio.lpe.irq; 174 174 175 - drm_WARN_ON(&dev_priv->drm, !intel_irqs_enabled(dev_priv)); 175 + drm_WARN_ON(display->drm, !intel_irqs_enabled(dev_priv)); 176 176 irq_set_chip_and_handler_name(irq, 177 177 &lpe_audio_irqchip, 178 178 handle_simple_irq, ··· 182 180 return irq_set_chip_data(irq, dev_priv); 183 181 } 184 182 185 - static bool lpe_audio_detect(struct drm_i915_private *dev_priv) 183 + static bool lpe_audio_detect(struct intel_display *display) 186 184 { 187 185 int lpe_present = false; 188 186 189 - if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { 187 + if (display->platform.valleyview || display->platform.cherryview) { 190 188 static const struct pci_device_id atom_hdaudio_ids[] = { 191 189 /* Baytrail */ 192 190 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0f04)}, ··· 196 194 }; 197 195 198 196 if (!pci_dev_present(atom_hdaudio_ids)) { 199 - drm_info(&dev_priv->drm, 197 + drm_info(display->drm, 200 198 "HDaudio controller not detected, using LPE audio instead\n"); 201 199 lpe_present = true; 202 200 } ··· 204 202 return lpe_present; 205 203 } 206 204 207 - static int lpe_audio_setup(struct drm_i915_private *dev_priv) 205 + static int lpe_audio_setup(struct intel_display *display) 208 206 { 209 207 int ret; 210 208 211 - dev_priv->display.audio.lpe.irq = irq_alloc_desc(0); 212 - if (dev_priv->display.audio.lpe.irq < 0) { 213 - drm_err(&dev_priv->drm, "Failed to allocate IRQ desc: %d\n", 214 - dev_priv->display.audio.lpe.irq); 215 - ret = dev_priv->display.audio.lpe.irq; 209 + display->audio.lpe.irq = irq_alloc_desc(0); 210 + if (display->audio.lpe.irq < 0) { 211 + drm_err(display->drm, "Failed to allocate IRQ desc: %d\n", 212 + display->audio.lpe.irq); 213 + ret = display->audio.lpe.irq; 216 214 goto err; 217 215 } 218 216 219 - drm_dbg(&dev_priv->drm, "irq = %d\n", dev_priv->display.audio.lpe.irq); 217 + drm_dbg(display->drm, "irq = %d\n", display->audio.lpe.irq); 220 218 221 - ret = lpe_audio_irq_init(dev_priv); 219 + ret = lpe_audio_irq_init(display); 222 220 223 221 if (ret) { 224 - drm_err(&dev_priv->drm, 222 + drm_err(display->drm, 225 223 "Failed to initialize irqchip for lpe audio: %d\n", 226 224 ret); 227 225 goto err_free_irq; 228 226 } 229 227 230 - dev_priv->display.audio.lpe.platdev = lpe_audio_platdev_create(dev_priv); 228 + display->audio.lpe.platdev = lpe_audio_platdev_create(display); 231 229 232 - if (IS_ERR(dev_priv->display.audio.lpe.platdev)) { 233 - ret = PTR_ERR(dev_priv->display.audio.lpe.platdev); 234 - drm_err(&dev_priv->drm, 230 + if (IS_ERR(display->audio.lpe.platdev)) { 231 + ret = PTR_ERR(display->audio.lpe.platdev); 232 + drm_err(display->drm, 235 233 "Failed to create lpe audio platform device: %d\n", 236 234 ret); 237 235 goto err_free_irq; ··· 240 238 /* enable chicken bit; at least this is required for Dell Wyse 3040 241 239 * with DP outputs (but only sometimes by some reason!) 242 240 */ 243 - intel_de_write(dev_priv, VLV_AUD_CHICKEN_BIT_REG, 241 + intel_de_write(display, VLV_AUD_CHICKEN_BIT_REG, 244 242 VLV_CHICKEN_BIT_DBG_ENABLE); 245 243 246 244 return 0; 247 245 err_free_irq: 248 - irq_free_desc(dev_priv->display.audio.lpe.irq); 246 + irq_free_desc(display->audio.lpe.irq); 249 247 err: 250 - dev_priv->display.audio.lpe.irq = -1; 251 - dev_priv->display.audio.lpe.platdev = NULL; 248 + display->audio.lpe.irq = -1; 249 + display->audio.lpe.platdev = NULL; 252 250 return ret; 253 251 } 254 252 255 253 /** 256 254 * intel_lpe_audio_irq_handler() - forwards the LPE audio irq 257 - * @dev_priv: the i915 drm device private data 255 + * @display: display device 258 256 * 259 257 * the LPE Audio irq is forwarded to the irq handler registered by LPE audio 260 258 * driver. 261 259 */ 262 - void intel_lpe_audio_irq_handler(struct drm_i915_private *dev_priv) 260 + void intel_lpe_audio_irq_handler(struct intel_display *display) 263 261 { 264 262 int ret; 265 263 266 - if (!HAS_LPE_AUDIO(dev_priv)) 264 + if (!HAS_LPE_AUDIO(display)) 267 265 return; 268 266 269 - ret = generic_handle_irq(dev_priv->display.audio.lpe.irq); 267 + ret = generic_handle_irq(display->audio.lpe.irq); 270 268 if (ret) 271 - drm_err_ratelimited(&dev_priv->drm, 269 + drm_err_ratelimited(display->drm, 272 270 "error handling LPE audio irq: %d\n", ret); 273 271 } 274 272 275 273 /** 276 274 * intel_lpe_audio_init() - detect and setup the bridge between HDMI LPE Audio 277 275 * driver and i915 278 - * @dev_priv: the i915 drm device private data 276 + * @display: display device 279 277 * 280 278 * Return: 0 if successful. non-zero if detection or 281 279 * llocation/initialization fails 282 280 */ 283 - int intel_lpe_audio_init(struct drm_i915_private *dev_priv) 281 + int intel_lpe_audio_init(struct intel_display *display) 284 282 { 285 283 int ret = -ENODEV; 286 284 287 - if (lpe_audio_detect(dev_priv)) { 288 - ret = lpe_audio_setup(dev_priv); 285 + if (lpe_audio_detect(display)) { 286 + ret = lpe_audio_setup(display); 289 287 if (ret < 0) 290 - drm_err(&dev_priv->drm, 288 + drm_err(display->drm, 291 289 "failed to setup LPE Audio bridge\n"); 292 290 } 293 291 return ret; ··· 296 294 /** 297 295 * intel_lpe_audio_teardown() - destroy the bridge between HDMI LPE 298 296 * audio driver and i915 299 - * @dev_priv: the i915 drm device private data 297 + * @display: display device 300 298 * 301 299 * release all the resources for LPE audio <-> i915 bridge. 302 300 */ 303 - void intel_lpe_audio_teardown(struct drm_i915_private *dev_priv) 301 + void intel_lpe_audio_teardown(struct intel_display *display) 304 302 { 305 - if (!HAS_LPE_AUDIO(dev_priv)) 303 + if (!HAS_LPE_AUDIO(display)) 306 304 return; 307 305 308 - lpe_audio_platdev_destroy(dev_priv); 306 + lpe_audio_platdev_destroy(display); 309 307 310 - irq_free_desc(dev_priv->display.audio.lpe.irq); 308 + irq_free_desc(display->audio.lpe.irq); 311 309 312 - dev_priv->display.audio.lpe.irq = -1; 313 - dev_priv->display.audio.lpe.platdev = NULL; 310 + display->audio.lpe.irq = -1; 311 + display->audio.lpe.platdev = NULL; 314 312 } 315 313 316 314 /** 317 315 * intel_lpe_audio_notify() - notify lpe audio event 318 316 * audio driver and i915 319 - * @dev_priv: the i915 drm device private data 317 + * @display: display device 320 318 * @cpu_transcoder: CPU transcoder 321 319 * @port: port 322 320 * @eld : ELD data ··· 325 323 * 326 324 * Notify lpe audio driver of eld change. 327 325 */ 328 - void intel_lpe_audio_notify(struct drm_i915_private *dev_priv, 326 + void intel_lpe_audio_notify(struct intel_display *display, 329 327 enum transcoder cpu_transcoder, enum port port, 330 328 const void *eld, int ls_clock, bool dp_output) 331 329 { ··· 334 332 struct intel_hdmi_lpe_audio_port_pdata *ppdata; 335 333 u32 audio_enable; 336 334 337 - if (!HAS_LPE_AUDIO(dev_priv)) 335 + if (!HAS_LPE_AUDIO(display)) 338 336 return; 339 337 340 - pdata = dev_get_platdata(&dev_priv->display.audio.lpe.platdev->dev); 338 + pdata = dev_get_platdata(&display->audio.lpe.platdev->dev); 341 339 ppdata = &pdata->port[port - PORT_B]; 342 340 343 341 spin_lock_irqsave(&pdata->lpe_audio_slock, irqflags); 344 342 345 - audio_enable = intel_de_read(dev_priv, VLV_AUD_PORT_EN_DBG(port)); 343 + audio_enable = intel_de_read(display, VLV_AUD_PORT_EN_DBG(port)); 346 344 347 345 if (eld != NULL) { 348 346 memcpy(ppdata->eld, eld, HDMI_MAX_ELD_BYTES); ··· 351 349 ppdata->dp_output = dp_output; 352 350 353 351 /* Unmute the amp for both DP and HDMI */ 354 - intel_de_write(dev_priv, VLV_AUD_PORT_EN_DBG(port), 352 + intel_de_write(display, VLV_AUD_PORT_EN_DBG(port), 355 353 audio_enable & ~VLV_AMP_MUTE); 356 354 } else { 357 355 memset(ppdata->eld, 0, HDMI_MAX_ELD_BYTES); ··· 360 358 ppdata->dp_output = false; 361 359 362 360 /* Mute the amp for both DP and HDMI */ 363 - intel_de_write(dev_priv, VLV_AUD_PORT_EN_DBG(port), 361 + intel_de_write(display, VLV_AUD_PORT_EN_DBG(port), 364 362 audio_enable | VLV_AMP_MUTE); 365 363 } 366 364 367 365 if (pdata->notify_audio_lpe) 368 - pdata->notify_audio_lpe(dev_priv->display.audio.lpe.platdev, port - PORT_B); 366 + pdata->notify_audio_lpe(display->audio.lpe.platdev, port - PORT_B); 369 367 370 368 spin_unlock_irqrestore(&pdata->lpe_audio_slock, irqflags); 371 369 }
+9 -9
drivers/gpu/drm/i915/display/intel_lpe_audio.h
··· 10 10 11 11 enum port; 12 12 enum transcoder; 13 - struct drm_i915_private; 13 + struct intel_display; 14 14 15 15 #ifdef I915 16 - int intel_lpe_audio_init(struct drm_i915_private *dev_priv); 17 - void intel_lpe_audio_teardown(struct drm_i915_private *dev_priv); 18 - void intel_lpe_audio_irq_handler(struct drm_i915_private *dev_priv); 19 - void intel_lpe_audio_notify(struct drm_i915_private *dev_priv, 16 + int intel_lpe_audio_init(struct intel_display *display); 17 + void intel_lpe_audio_teardown(struct intel_display *display); 18 + void intel_lpe_audio_irq_handler(struct intel_display *display); 19 + void intel_lpe_audio_notify(struct intel_display *display, 20 20 enum transcoder cpu_transcoder, enum port port, 21 21 const void *eld, int ls_clock, bool dp_output); 22 22 #else 23 - static inline int intel_lpe_audio_init(struct drm_i915_private *dev_priv) 23 + static inline int intel_lpe_audio_init(struct intel_display *display) 24 24 { 25 25 return -ENODEV; 26 26 } 27 - static inline void intel_lpe_audio_teardown(struct drm_i915_private *dev_priv) 27 + static inline void intel_lpe_audio_teardown(struct intel_display *display) 28 28 { 29 29 } 30 - static inline void intel_lpe_audio_irq_handler(struct drm_i915_private *dev_priv) 30 + static inline void intel_lpe_audio_irq_handler(struct intel_display *display) 31 31 { 32 32 } 33 - static inline void intel_lpe_audio_notify(struct drm_i915_private *dev_priv, 33 + static inline void intel_lpe_audio_notify(struct intel_display *display, 34 34 enum transcoder cpu_transcoder, enum port port, 35 35 const void *eld, int ls_clock, bool dp_output) 36 36 {
+4 -2
drivers/gpu/drm/i915/i915_irq.c
··· 207 207 static irqreturn_t valleyview_irq_handler(int irq, void *arg) 208 208 { 209 209 struct drm_i915_private *dev_priv = arg; 210 + struct intel_display *display = &dev_priv->display; 210 211 irqreturn_t ret = IRQ_NONE; 211 212 212 213 if (!intel_irqs_enabled(dev_priv)) ··· 261 260 262 261 if (iir & (I915_LPE_PIPE_A_INTERRUPT | 263 262 I915_LPE_PIPE_B_INTERRUPT)) 264 - intel_lpe_audio_irq_handler(dev_priv); 263 + intel_lpe_audio_irq_handler(display); 265 264 266 265 /* 267 266 * VLV_IIR is single buffered, and reflects the level ··· 294 293 static irqreturn_t cherryview_irq_handler(int irq, void *arg) 295 294 { 296 295 struct drm_i915_private *dev_priv = arg; 296 + struct intel_display *display = &dev_priv->display; 297 297 irqreturn_t ret = IRQ_NONE; 298 298 299 299 if (!intel_irqs_enabled(dev_priv)) ··· 345 343 if (iir & (I915_LPE_PIPE_A_INTERRUPT | 346 344 I915_LPE_PIPE_B_INTERRUPT | 347 345 I915_LPE_PIPE_C_INTERRUPT)) 348 - intel_lpe_audio_irq_handler(dev_priv); 346 + intel_lpe_audio_irq_handler(display); 349 347 350 348 /* 351 349 * VLV_IIR is single buffered, and reflects the level