aboutsummaryrefslogtreecommitdiffstats
path: root/classes/fsl-vivante-kernel-driver-handler.bbclass
blob: e0578f4e2585fa20277b0f726c8c4dfe34ed80b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Freescale Kernel Vivante Kernel Driver handler
#
# Enable the kernel to provide or not the Vivante kernel driver and
#  dynamically set the proper providers per machine.
#
# The following options are supported:
#
#  MACHINE_HAS_VIVANTE_KERNEL_DRIVER_SUPPORT
#
#     Machine does or does not have support for the Vivante kernel
#     driver, options are:
#
#       0 - machine does not have Vivante GPU driver support
#       1 - machine has Vivante GPU driver support
#
#  MACHINE_USES_VIVANTE_KERNEL_DRIVER_MODULE
#
#      Machine uses the Vivante kernel driver as module, options are:
#
#       0 - enable the builtin kernel driver module
#       1 - enable the external kernel module
#
# Copyright 2015, 2016 (C) O.S. Systems Software LTDA.
# Released under the MIT license (see COPYING.MIT for the terms)

# Handle Vivante kernel driver setting:
#   0 - machine does not have Vivante GPU driver support
#   1 - machine has Vivante GPU driver support
MACHINE_HAS_VIVANTE_KERNEL_DRIVER_SUPPORT ??= "0"

# Use Vivante kernel driver module:
#   0 - enable the builtin kernel driver module
#   1 - enable the external kernel module
MACHINE_USES_VIVANTE_KERNEL_DRIVER_MODULE ??= "${@d.getVar('MACHINE_HAS_VIVANTE_KERNEL_DRIVER_SUPPORT', False) or '0'}"

python fsl_vivante_kernel_driver_handler () {
    has_vivante_kernel_driver_support = e.data.getVar('MACHINE_HAS_VIVANTE_KERNEL_DRIVER_SUPPORT', True) or "0"
    use_vivante_kernel_driver_module = e.data.getVar('MACHINE_USES_VIVANTE_KERNEL_DRIVER_MODULE', True) or "0"

    if has_vivante_kernel_driver_support != "1":
        return

    if use_vivante_kernel_driver_module != "1":
        e.data.appendVar('RPROVIDES_kernel-base', ' kernel-module-imx-gpu-viv')
        e.data.appendVar('RREPLACES_kernel-base', ' kernel-module-imx-gpu-viv')
        e.data.appendVar('RCONFLICTS_kernel-base', ' kernel-module-imx-gpu-viv')
}

addhandler fsl_vivante_kernel_driver_handler
fsl_vivante_kernel_driver_handler[eventmask] = "bb.event.RecipePreFinalise"

do_configure_append () {
    if [ "${MACHINE_HAS_VIVANTE_KERNEL_DRIVER_SUPPORT}" = "1" ]; then
        config="${B}/.config"

        sed -i "/CONFIG_MXC_GPU_VIV[ =]/d" $config
        if [ "${MACHINE_USES_VIVANTE_KERNEL_DRIVER_MODULE}" = "1" ]; then
            echo "# CONFIG_MXC_GPU_VIV is not set" >> $config
        else
            echo "CONFIG_MXC_GPU_VIV=y" >> $config
        fi
    fi
}