aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/samsung/mali/Kbuild_module
blob: e8659545a8c16e38ec8c8342886efad8c4d71c58 (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
#
# Copyright (C) 2010-2011 ARM Limited. All rights reserved.
# 
# This program is free software and is provided to you under the terms of the GNU General Public License version 2
# as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
# 
# A copy of the licence is included with the program, and can also be obtained from Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
#

# This file is called by the Linux build system.

OSKOS=linux

# set up defaults if not defined by the user
USING_UMP ?= 0
USING_OS_MEMORY ?= 0
USING_MALI_PMM_TESTSUITE ?= 0
OS_MEMORY_KERNEL_BUFFER_SIZE_IN_MB ?= 16
USING_PROFILING ?= 1
USING_INTERNAL_PROFILING ?= 0
DISABLE_PP0 ?= 0
DISABLE_PP1 ?= 0
DISABLE_PP2 ?= 0
DISABLE_PP3 ?= 0
PROFILING_SKIP_PP_JOBS ?= 0
PROFILING_SKIP_PP_AND_GP_JOBS ?= 0
PROFILING_PRINT_L2_HITRATE_ON_GP_FINISH ?= 0
TIMESTAMP ?= default
BUILD ?= debug
TARGET_PLATFORM ?= default
KERNEL_RUNTIME_PM_ENABLED ?= 0
CONFIG ?= pb-virtex5-m200
MALI_PP_SCHEDULER_FORCE_NO_JOB_OVERLAP ?= 0
MALI_PP_SCHEDULER_KEEP_SUB_JOB_STARTS_ALIGNED ?= 0
MALI_PP_SCHEDULER_FORCE_NO_JOB_OVERLAP_BETWEEN_APPS ?= 0

DEFINES := $(EXTRA_DEFINES)

# Get path to driver source from Linux build system
DRIVER_DIR=$(src)

# For customer releases the Linux Device Drivers will be provided as ARM proprietary and GPL releases:
# The ARM proprietary product will only include the license/proprietary directory
# The GPL product will only include the license/gpl directory

ifeq ($(wildcard $(DRIVER_DIR)/linux/license/gpl/*),)
ccflags-y += -I$(DRIVER_DIR)/linux/license/proprietary
# Disable profiling for proprietary
override USING_PROFILING := 0
$(warning "USING_PROFILING not supported, disabling.")
else
ccflags-y += -I$(DRIVER_DIR)/linux/license/gpl
endif


ifeq ($(USING_PROFILING),1)
ifeq ($(USING_INTERNAL_PROFILING),0)
ifndef CONFIG_TRACEPOINTS
# Should default to gator profiling, but we dont have the kernel feature required, so disable profiling
override USING_PROFILING = 0
$(warning "CONFIG_TRACEPOINTS required for USING_PROFILING")
endif
endif
endif

ifeq ($(USING_PROFILING),0)
# make sure user hasnt selected incompatible flags
override USING_INTERNAL_PROFILING = 0
endif

MALI_RELEASE_NAME=$(shell cat $(DRIVER_DIR)/.version 2> /dev/null)

# Check if a Mali Core sub module should be enabled, true or false returned
submodule_enabled = $(shell gcc $(DEFINES) -E $1/arch/config.h | grep type | grep -c $(2))

OSKFILES = \
	$(OSKOS)/mali_osk_atomics.c \
	$(OSKOS)/mali_osk_irq.c \
	$(OSKOS)/mali_osk_locks.c \
	$(OSKOS)/mali_osk_wait_queue.c \
	$(OSKOS)/mali_osk_low_level_mem.c \
	$(OSKOS)/mali_osk_math.c \
	$(OSKOS)/mali_osk_memory.c \
	$(OSKOS)/mali_osk_misc.c \
	$(OSKOS)/mali_osk_mali.c \
	$(OSKOS)/mali_osk_notification.c \
	$(OSKOS)/mali_osk_time.c \
	$(OSKOS)/mali_osk_timers.c

UKKFILES = \
	$(OSKOS)/mali_ukk_mem.c \
	$(OSKOS)/mali_ukk_gp.c \
	$(OSKOS)/mali_ukk_pp.c \
	$(OSKOS)/mali_ukk_core.c

ifeq ($(USING_PROFILING),1)
UKKFILES += \
	$(OSKOS)/mali_ukk_profiling.c
endif

ifeq ($(MALI_PLATFORM_FILE),)
MALI_PLATFORM_FILE = platform/default/mali_platform.c
endif

# Get subversion revision number, fall back to only ${MALI_RELEASE_NAME} if no svn info is available
SVN_REV := $(shell (cd $(DRIVER_DIR); (svnversion | grep -E "^[0-9]+" && svnversion) || git svn info | grep '^Revision: '| sed -e 's/^Revision: //' ) 2>/dev/null )
ifeq ($(SVN_REV),)
SVN_REV := $(MALI_RELEASE_NAME)
else
SVN_REV := $(MALI_RELEASE_NAME)-r$(SVN_REV)
endif

# Validate selected config
ifneq ($(shell [ -d $(DRIVER_DIR)/arch-$(CONFIG) ] && [ -f $(DRIVER_DIR)/arch-$(CONFIG)/config.h ] && echo "OK"), OK)
$(warning Current directory is $(shell pwd))
$(error No configuration found for config $(CONFIG). Check that arch-$(CONFIG)/config.h exists)
else
# Link arch to the selected arch-config directory
$(shell [ -L $(DRIVER_DIR)/arch ] && rm $(DRIVER_DIR)/arch)
$(shell ln -sf arch-$(CONFIG) $(DRIVER_DIR)/arch)
$(shell touch $(DRIVER_DIR)/arch/config.h)
endif

# Set up our defines, which will be passed to gcc
DEFINES += -DUSING_OS_MEMORY=$(USING_OS_MEMORY)
DEFINES += -DUSING_MMU=1
DEFINES += -DUSING_UMP=$(USING_UMP)
DEFINES += -D_MALI_OSK_SPECIFIC_INDIRECT_MMAP
DEFINES += -DMALI_INTERNAL_TIMELINE_PROFILING_ENABLED=$(USING_INTERNAL_PROFILING)
DEFINES += -DDISABLE_PP0=$(DISABLE_PP0)
DEFINES += -DDISABLE_PP1=$(DISABLE_PP1)
DEFINES += -DDISABLE_PP2=$(DISABLE_PP2)
DEFINES += -DDISABLE_PP3=$(DISABLE_PP3)
DEFINES += -DPROFILING_SKIP_PP_JOBS=$(PROFILING_SKIP_PP_JOBS)
DEFINES += -DPROFILING_SKIP_PP_AND_GP_JOBS=$(PROFILING_SKIP_PP_AND_GP_JOBS)
DEFINES += -DPROFILING_PRINT_L2_HITRATE_ON_GP_FINISH=$(PROFILING_PRINT_L2_HITRATE_ON_GP_FINISH)

DEFINES += -DMALI_PP_SCHEDULER_FORCE_NO_JOB_OVERLAP=$(MALI_PP_SCHEDULER_FORCE_NO_JOB_OVERLAP)
DEFINES += -DMALI_PP_SCHEDULER_KEEP_SUB_JOB_STARTS_ALIGNED=$(MALI_PP_SCHEDULER_KEEP_SUB_JOB_STARTS_ALIGNED)
DEFINES += -DMALI_PP_SCHEDULER_FORCE_NO_JOB_OVERLAP_BETWEEN_APPS=$(MALI_PP_SCHEDULER_FORCE_NO_JOB_OVERLAP_BETWEEN_APPS)
DEFINES += -DMALI_TIMELINE_PROFILING_ENABLED=$(USING_PROFILING)
DEFINES += -DMALI_POWER_MGMT_TEST_SUITE=$(USING_MALI_PMM_TESTSUITE)
ifeq ($(shell test $(SUBLEVEL) -gt 32 -a $(PATCHLEVEL) = 6 -a $(VERSION) = 2 -o $(VERSION) -gt 2 && echo "OK"),OK)
# MALI_STATE_TRACKING is only supported on Linux kernels from version 2.6.32.
DEFINES += -DMALI_STATE_TRACKING=1
else
DEFINES += -DMALI_STATE_TRACKING=0
endif
DEFINES += -DMALI_OS_MEMORY_KERNEL_BUFFER_SIZE_IN_MB=$(OS_MEMORY_KERNEL_BUFFER_SIZE_IN_MB)

MALI_PLATFORM_FILE = platform/$(TARGET_PLATFORM)/mali_platform.c


ifdef CONFIG_PM
ifdef CONFIG_PM_RUNTIME
	KERNEL_RUNTIME_PM_ENABLED = 1
endif
endif

DEFINES += -DMALI_PMM_RUNTIME_JOB_CONTROL_ON=$(KERNEL_RUNTIME_PM_ENABLED)

ifeq ($(BUILD), debug)
DEFINES += -DDEBUG
endif
DEFINES += -DSVN_REV=$(SVN_REV)
DEFINES += -DSVN_REV_STRING=\"$(SVN_REV)\"

# Linux has its own mmap cleanup handlers (see mali_kernel_memory.c)
DEFINES += -DMALI_UKK_HAS_IMPLICIT_MMAP_CLEANUP

ifeq ($(USING_UMP),1)
	DEFINES += -DMALI_USE_UNIFIED_MEMORY_PROVIDER=1
	ccflags-y += -I$(DRIVER_DIR)/../../ump/include/ump
else
	DEFINES += -DMALI_USE_UNIFIED_MEMORY_PROVIDER=0
endif

# Use our defines when compiling
ccflags-y += $(DEFINES) -I$(DRIVER_DIR) -I$(DRIVER_DIR)/include -I$(DRIVER_DIR)/common -I$(DRIVER_DIR)/linux -I$(DRIVER_DIR)/platform

# Source files which always are included in a build
SRC = \
	common/mali_kernel_core.c \
	linux/mali_kernel_linux.c \
	common/mali_kernel_descriptor_mapping.c \
	common/mali_session.c \
	common/mali_device_pause_resume.c \
	common/mali_kernel_vsync.c \
	linux/mali_ukk_vsync.c \
	linux/mali_kernel_sysfs.c \
	common/mali_mmu.c \
	common/mali_mmu_page_directory.c \
	common/mali_memory.c \
	common/mali_kernel_memory_engine.c \
	common/mali_block_allocator.c \
	common/mali_kernel_mem_os.c \
	common/mali_mem_validation.c \
	common/mali_hw_core.c \
	common/mali_gp.c \
	common/mali_pp.c \
	common/mali_pp_job.c \
	common/mali_gp_job.c \
	common/mali_scheduler.c \
	common/mali_gp_scheduler.c \
	common/mali_pp_scheduler.c \
	common/mali_cluster.c \
	common/mali_group.c \
	common/mali_dlbu.c \
	common/mali_pm.c \
	common/mali_pmu.c \
	common/mali_user_settings_db.c \
	$(OSKOS)/mali_osk_pm.c \
	linux/mali_kernel_pm.c \
	linux/mali_pmu_power_up_down.c \
	$(MALI_PLATFORM_FILE) \
	$(OSKFILES) \
	$(UKKFILES) \
	__malidrv_build_info.c

# Selecting files to compile by parsing the config file

ifeq ($(USING_INTERNAL_PROFILING),1)
PROFILING_BACKEND_SOURCES = \
    linux/mali_osk_profiling_internal.c \
    timestamp-$(TIMESTAMP)/mali_timestamp.c
ccflags-y += -I$(DRIVER_DIR)/timestamp-$(TIMESTAMP)
else
ifeq ($(USING_PROFILING),1)
PROFILING_BACKEND_SOURCES = \
    linux/mali_osk_profiling_gator.c
endif
endif

# Add the profiling sources
SRC += $(PROFILING_BACKEND_SOURCES)

ifeq ($(USING_MALI_PMM_TESTSUITE),1)
ccflags-y += -I$(DRIVER_DIR)/platform/mali_pmu_testing
endif

mali-$(CONFIG_MALI400_GPU_UTILIZATION) += common/mali_kernel_utilization.o
mali-$(CONFIG_DMA_SHARED_BUFFER) += linux/mali_dma_buf.o

ifneq ($(call submodule_enabled, $(DRIVER_DIR), MALI400PP),0)
	# Mali-400 PP in use
	ccflags-y += -DUSING_MALI400
endif

ifneq ($(call submodule_enabled, $(DRIVER_DIR), MALI300PP),0)
	# Mali-400 PP in use
	ccflags-y += -DUSING_MALI400
endif

ifneq ($(call submodule_enabled, $(DRIVER_DIR), MALI200),0)
	# Mali200 in use
	ccflags-y += -DUSING_MALI200
endif

# Always build in support for Mali L2 cache
SRC += common/mali_l2_cache.c

# Tell the Linux build system to enable building of our .c files
mali-y += $(SRC:.c=.o)
# Tell the Linux build system from which .o file to create the kernel module
obj-$(CONFIG_MALI400) := mali.o


VERSION_STRINGS :=
VERSION_STRINGS += CONFIG=$(CONFIG)
VERSION_STRINGS += USING_OS_MEMORY=$(USING_OS_MEMORY)
VERSION_STRINGS += API_VERSION=$(shell cd $(DRIVER_DIR); grep "\#define _MALI_API_VERSION" $(FILES_PREFIX)include/linux/mali/mali_utgard_uk_types.h | cut -d' ' -f 3 )
VERSION_STRINGS += REPO_URL=$(shell cd $(DRIVER_DIR); (svn info || git svn info || echo 'URL: $(MALI_RELEASE_NAME)') 2>/dev/null | grep '^URL: ' | cut -d: -f2- | cut -b2-)
VERSION_STRINGS += REVISION=$(SVN_REV)
VERSION_STRINGS += CHANGED_REVISION=$(shell cd $(DRIVER_DIR); (svn info || git svn info || echo 'Last Changed Rev: $(MALI_RELEASE_NAME)') 2>/dev/null | grep '^Last Changed Rev: ' | cut -d: -f2- | cut -b2-)
VERSION_STRINGS += CHANGE_DATE=$(shell cd $(DRIVER_DIR); (svn info || git svn info || echo 'Last Changed Date: $(MALI_RELEASE_NAME)') 2>/dev/null | grep '^Last Changed Date: ' | cut -d: -f2- | cut -b2-)
VERSION_STRINGS += BUILD_DATE=$(shell date)

VERSION_STRINGS += BUILD=$(shell echo $(BUILD) | tr a-z A-Z)
VERSION_STRINGS += CPU=$(CPU)
VERSION_STRINGS += USING_UMP=$(USING_UMP)
VERSION_STRINGS += USING_MALI200=$(call submodule_enabled, $(DRIVER_DIR), MALI200)
VERSION_STRINGS += USING_MALI400=$(call submodule_enabled, $(DRIVER_DIR), MALI400)
VERSION_STRINGS += USING_MALI400_L2_CACHE=$(call submodule_enabled, $(DRIVER_DIR), MALI400L2)
VERSION_STRINGS += USING_GP2=$(call submodule_enabled, $(DRIVER_DIR), MALIGP2)
VERSION_STRINGS += KDIR=$(KDIR)
VERSION_STRINGS += MALI_PLATFORM_FILE=$(MALI_PLATFORM_FILE)
VERSION_STRINGS += OS_MEMORY_KERNEL_BUFFER_SIZE_IN_MB=$(OS_MEMORY_KERNEL_BUFFER_SIZE_IN_MB)
VERSION_STRINGS += USING_PROFILING=$(USING_PROFILING)
VERSION_STRINGS += USING_INTERNAL_PROFILING=$(USING_INTERNAL_PROFILING)
VERSION_STRINGS += USING_GPU_UTILIZATION=$(CONFIG_MALI400_GPU_UTILIZATION)

# Create file with Mali driver configuration
$(DRIVER_DIR)/__malidrv_build_info.c:
	@echo 'const char *__malidrv_build_info(void) { return "malidrv: $(VERSION_STRINGS)";}' > $(DRIVER_DIR)/__malidrv_build_info.c