	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function lpt_setup_backlight
_lpt_setup_backlight:                   ## @lpt_setup_backlight
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	pushq	%rax
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdi, %r15
	movl	4(%rdi), %edi
	callq	_to_i915
	movq	%rax, %r12
	movq	%rax, %rdi
	callq	_HAS_PCH_LPT
	testq	%rax, %rax
	movq	_SOUTH_CHICKEN2@GOTPCREL(%rip), %rax
	cmoveq	_SOUTH_CHICKEN1@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movq	_LPT_PWM_GRANULARITY@GOTPCREL(%rip), %rbx
	cmoveq	_SPT_PWM_GRANULARITY@GOTPCREL(%rip), %rbx
	callq	_I915_READ
	andl	(%rbx), %eax
	movl	%eax, 8(%r15)
	movq	_BLC_PWM_PCH_CTL1@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_I915_READ
	movl	%eax, %r14d
	movq	_BLM_PCH_POLARITY@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	andl	%r14d, %eax
	movl	%eax, 12(%r15)
	movq	_BLC_PWM_PCH_CTL2@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_I915_READ
	sarl	$16, %eax
	movl	%eax, 16(%r15)
	movq	_BLC_PWM_CPU_CTL2@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_I915_READ
	movl	%eax, %ebx
	cmpl	$0, 16(%r15)
	jne	LBB0_3
## %bb.1:
	movq	%r15, %rdi
	callq	_get_backlight_max_vbt
	movl	%eax, 16(%r15)
	testl	%eax, %eax
	je	LBB0_2
LBB0_3:
	movq	%r15, %rdi
	callq	_get_backlight_min_vbt
	movl	%eax, 28(%r15)
	movq	_BLM_PCH_PWM_ENABLE@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	andl	%r14d, %eax
	movl	%eax, 20(%r15)
	je	LBB0_8
## %bb.4:
	movq	%r12, %rdi
	callq	_HAS_PCH_LPT
	testq	%rax, %rax
	je	LBB0_8
## %bb.5:
	movq	_BLM_PCH_OVERRIDE_ENABLE@GOTPCREL(%rip), %rax
	testl	%r14d, (%rax)
	je	LBB0_6
LBB0_8:
	movq	%r15, %rdi
	callq	_lpt_get_backlight
	xorl	%r13d, %r13d
LBB0_9:
	movq	%r15, %rdi
	movl	%eax, %esi
	callq	_intel_panel_compute_brightness
	movl	16(%r15), %edx
	movl	28(%r15), %esi
	movl	%eax, %edi
	callq	_clamp
	movl	%eax, 24(%r15)
	xorl	%r12d, %r12d
	testb	%r13b, %r13b
	je	LBB0_11
## %bb.10:
	leaq	L_.str(%rip), %rdi
	callq	_DRM_DEBUG_KMS
	movl	(%r15), %edi
	movl	24(%r15), %esi
	callq	_lpt_set_backlight
	movq	_BLC_PWM_PCH_CTL1@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movq	_BLM_PCH_OVERRIDE_ENABLE@GOTPCREL(%rip), %rax
	orl	(%rax), %r14d
	movl	%r14d, %esi
	callq	_I915_WRITE
	movq	_BLC_PWM_CPU_CTL2@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movq	_BLM_PWM_ENABLE@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	notl	%eax
	andl	%eax, %ebx
	movl	%ebx, %esi
	callq	_I915_WRITE
	jmp	LBB0_11
LBB0_2:
	movq	_ENODEV@GOTPCREL(%rip), %rax
	xorl	%r12d, %r12d
	subl	(%rax), %r12d
LBB0_11:
	movl	%r12d, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_6:
	movq	_BLM_PWM_ENABLE@GOTPCREL(%rip), %rax
	testl	%ebx, (%rax)
	je	LBB0_8
## %bb.7:
	movq	%r15, %rdi
	callq	_pch_get_backlight
	movb	$1, %r13b
	jmp	LBB0_9
	.cfi_endproc
                                        ## -- End function
	.comm	_SOUTH_CHICKEN2,4,2             ## @SOUTH_CHICKEN2
	.comm	_LPT_PWM_GRANULARITY,4,2        ## @LPT_PWM_GRANULARITY
	.comm	_SOUTH_CHICKEN1,4,2             ## @SOUTH_CHICKEN1
	.comm	_SPT_PWM_GRANULARITY,4,2        ## @SPT_PWM_GRANULARITY
	.comm	_BLC_PWM_PCH_CTL1,4,2           ## @BLC_PWM_PCH_CTL1
	.comm	_BLM_PCH_POLARITY,4,2           ## @BLM_PCH_POLARITY
	.comm	_BLC_PWM_PCH_CTL2,4,2           ## @BLC_PWM_PCH_CTL2
	.comm	_BLC_PWM_CPU_CTL2,4,2           ## @BLC_PWM_CPU_CTL2
	.comm	_ENODEV,4,2                     ## @ENODEV
	.comm	_BLM_PCH_PWM_ENABLE,4,2         ## @BLM_PCH_PWM_ENABLE
	.comm	_BLM_PCH_OVERRIDE_ENABLE,4,2    ## @BLM_PCH_OVERRIDE_ENABLE
	.comm	_BLM_PWM_ENABLE,4,2             ## @BLM_PWM_ENABLE
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"CPU backlight register was enabled, switching to PCH override\n"

	.no_dead_strip	_lpt_setup_backlight
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function lpt_setup_backlight
_lpt_setup_backlight:                   ; @lpt_setup_backlight
	.cfi_startproc
; %bb.0:
	stp	x24, x23, [sp, #-64]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 64
	stp	x22, x21, [sp, #16]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #32]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #48]             ; 16-byte Folded Spill
	add	x29, sp, #48
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	.cfi_offset w19, -24
	.cfi_offset w20, -32
	.cfi_offset w21, -40
	.cfi_offset w22, -48
	.cfi_offset w23, -56
	.cfi_offset w24, -64
	mov	x19, x0
	ldr	w0, [x0, #4]
	bl	_to_i915
	mov	x22, x0
	bl	_HAS_PCH_LPT
Lloh0:
	adrp	x8, _SOUTH_CHICKEN1@GOTPAGE
Lloh1:
	ldr	x8, [x8, _SOUTH_CHICKEN1@GOTPAGEOFF]
Lloh2:
	adrp	x9, _SOUTH_CHICKEN2@GOTPAGE
Lloh3:
	ldr	x9, [x9, _SOUTH_CHICKEN2@GOTPAGEOFF]
	cmp	x0, #0
	csel	x8, x8, x9, eq
	ldr	w0, [x8]
Lloh4:
	adrp	x8, _SPT_PWM_GRANULARITY@GOTPAGE
Lloh5:
	ldr	x8, [x8, _SPT_PWM_GRANULARITY@GOTPAGEOFF]
Lloh6:
	adrp	x9, _LPT_PWM_GRANULARITY@GOTPAGE
Lloh7:
	ldr	x9, [x9, _LPT_PWM_GRANULARITY@GOTPAGEOFF]
	csel	x20, x8, x9, eq
	bl	_I915_READ
	ldr	w8, [x20]
	and	w8, w8, w0
	str	w8, [x19, #8]
Lloh8:
	adrp	x23, _BLC_PWM_PCH_CTL1@GOTPAGE
Lloh9:
	ldr	x23, [x23, _BLC_PWM_PCH_CTL1@GOTPAGEOFF]
	ldr	w0, [x23]
	bl	_I915_READ
	mov	x20, x0
Lloh10:
	adrp	x8, _BLM_PCH_POLARITY@GOTPAGE
Lloh11:
	ldr	x8, [x8, _BLM_PCH_POLARITY@GOTPAGEOFF]
Lloh12:
	ldr	w8, [x8]
	and	w8, w8, w0
	str	w8, [x19, #12]
Lloh13:
	adrp	x8, _BLC_PWM_PCH_CTL2@GOTPAGE
Lloh14:
	ldr	x8, [x8, _BLC_PWM_PCH_CTL2@GOTPAGEOFF]
Lloh15:
	ldr	w0, [x8]
	bl	_I915_READ
	asr	w8, w0, #16
	str	w8, [x19, #16]
Lloh16:
	adrp	x24, _BLC_PWM_CPU_CTL2@GOTPAGE
Lloh17:
	ldr	x24, [x24, _BLC_PWM_CPU_CTL2@GOTPAGEOFF]
	ldr	w0, [x24]
	bl	_I915_READ
	mov	x21, x0
	ldr	w8, [x19, #16]
	cbnz	w8, LBB0_2
; %bb.1:
	mov	x0, x19
	bl	_get_backlight_max_vbt
	str	w0, [x19, #16]
	cbz	w0, LBB0_10
LBB0_2:
	mov	x0, x19
	bl	_get_backlight_min_vbt
	str	w0, [x19, #28]
Lloh18:
	adrp	x8, _BLM_PCH_PWM_ENABLE@GOTPAGE
Lloh19:
	ldr	x8, [x8, _BLM_PCH_PWM_ENABLE@GOTPAGEOFF]
Lloh20:
	ldr	w8, [x8]
	ands	w8, w8, w20
	str	w8, [x19, #20]
	b.eq	LBB0_5
; %bb.3:
	mov	x0, x22
	bl	_HAS_PCH_LPT
	cbz	x0, LBB0_5
; %bb.4:
Lloh21:
	adrp	x8, _BLM_PCH_OVERRIDE_ENABLE@GOTPAGE
Lloh22:
	ldr	x8, [x8, _BLM_PCH_OVERRIDE_ENABLE@GOTPAGEOFF]
Lloh23:
	ldr	w8, [x8]
	tst	w8, w20
	b.eq	LBB0_11
LBB0_5:
	mov	x0, x19
	bl	_lpt_get_backlight
	mov	x1, x0
	mov	w22, #0
LBB0_6:
	mov	x0, x19
	bl	_intel_panel_compute_brightness
	ldr	w1, [x19, #28]
	ldr	w2, [x19, #16]
	bl	_clamp
	str	w0, [x19, #24]
	cbz	w22, LBB0_8
; %bb.7:
Lloh24:
	adrp	x0, l_.str@PAGE
Lloh25:
	add	x0, x0, l_.str@PAGEOFF
	bl	_DRM_DEBUG_KMS
	ldr	w0, [x19]
	ldr	w1, [x19, #24]
	bl	_lpt_set_backlight
	ldr	w0, [x23]
Lloh26:
	adrp	x8, _BLM_PCH_OVERRIDE_ENABLE@GOTPAGE
Lloh27:
	ldr	x8, [x8, _BLM_PCH_OVERRIDE_ENABLE@GOTPAGEOFF]
Lloh28:
	ldr	w8, [x8]
	orr	w1, w8, w20
	bl	_I915_WRITE
	ldr	w0, [x24]
Lloh29:
	adrp	x8, _BLM_PWM_ENABLE@GOTPAGE
Lloh30:
	ldr	x8, [x8, _BLM_PWM_ENABLE@GOTPAGEOFF]
Lloh31:
	ldr	w8, [x8]
	bic	w1, w21, w8
	bl	_I915_WRITE
LBB0_8:
	mov	w0, #0
LBB0_9:
	ldp	x29, x30, [sp, #48]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #32]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #16]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp], #64             ; 16-byte Folded Reload
	ret
LBB0_10:
Lloh32:
	adrp	x8, _ENODEV@GOTPAGE
Lloh33:
	ldr	x8, [x8, _ENODEV@GOTPAGEOFF]
Lloh34:
	ldr	w8, [x8]
	neg	w0, w8
	b	LBB0_9
LBB0_11:
Lloh35:
	adrp	x8, _BLM_PWM_ENABLE@GOTPAGE
Lloh36:
	ldr	x8, [x8, _BLM_PWM_ENABLE@GOTPAGEOFF]
Lloh37:
	ldr	w8, [x8]
	tst	w8, w21
	b.eq	LBB0_5
; %bb.12:
	mov	x0, x19
	bl	_pch_get_backlight
	mov	x1, x0
	mov	w22, #1
	b	LBB0_6
	.loh AdrpLdrGot	Lloh16, Lloh17
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh12
	.loh AdrpLdrGot	Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh18, Lloh19, Lloh20
	.loh AdrpLdrGotLdr	Lloh21, Lloh22, Lloh23
	.loh AdrpLdrGotLdr	Lloh29, Lloh30, Lloh31
	.loh AdrpLdrGotLdr	Lloh26, Lloh27, Lloh28
	.loh AdrpAdd	Lloh24, Lloh25
	.loh AdrpLdrGotLdr	Lloh32, Lloh33, Lloh34
	.loh AdrpLdrGotLdr	Lloh35, Lloh36, Lloh37
	.cfi_endproc
                                        ; -- End function
	.comm	_SOUTH_CHICKEN2,4,2             ; @SOUTH_CHICKEN2
	.comm	_LPT_PWM_GRANULARITY,4,2        ; @LPT_PWM_GRANULARITY
	.comm	_SOUTH_CHICKEN1,4,2             ; @SOUTH_CHICKEN1
	.comm	_SPT_PWM_GRANULARITY,4,2        ; @SPT_PWM_GRANULARITY
	.comm	_BLC_PWM_PCH_CTL1,4,2           ; @BLC_PWM_PCH_CTL1
	.comm	_BLM_PCH_POLARITY,4,2           ; @BLM_PCH_POLARITY
	.comm	_BLC_PWM_PCH_CTL2,4,2           ; @BLC_PWM_PCH_CTL2
	.comm	_BLC_PWM_CPU_CTL2,4,2           ; @BLC_PWM_CPU_CTL2
	.comm	_ENODEV,4,2                     ; @ENODEV
	.comm	_BLM_PCH_PWM_ENABLE,4,2         ; @BLM_PCH_PWM_ENABLE
	.comm	_BLM_PCH_OVERRIDE_ENABLE,4,2    ; @BLM_PCH_OVERRIDE_ENABLE
	.comm	_BLM_PWM_ENABLE,4,2             ; @BLM_PWM_ENABLE
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"CPU backlight register was enabled, switching to PCH override\n"

	.no_dead_strip	_lpt_setup_backlight
.subsections_via_symbols
