mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
* [ptxdist] kernel headers in ptxdist
@ 2017-01-31  9:27 Alejandro Vázquez
  2017-01-31  9:49 ` Juergen Borleis
  0 siblings, 1 reply; 3+ messages in thread
From: Alejandro Vázquez @ 2017-01-31  9:27 UTC (permalink / raw)
  To: ptxdist


[-- Attachment #1.1: Type: text/plain, Size: 768 bytes --]

Hi, All.

I need use kernel headers to build a IPU app.
I select KERNEL_HEADERS in ptxdist and I add
CFLAGS="-I$(KERNEL_HEADERS_INCLUDE_DIR)" in *.make.
Also I have added in the makefile -I$(KERNEL_HEADERS_INCLUDE_DIR)

But it still does not compile because it does not find the headers.
It looks like the variable KERNEL_HEADERS_INCLUDE_DIR is empty, this can be
seen in the output of the compilation.

-------------------------
> target: alpha_ex1.compile
> -------------------------
> make[1]: Entering directory `/ptxdist/BSP/local_src/alpha_ex1'
> arm-v7a-linux-gnueabihf-gcc -g -O0 -o alpha_ex1 alpha_ex1.c -I \
> -I/uapi
> alpha_ex1.c:26:25: fatal error: linux/mxcfb.h: No such file or directory
>  #include <linux/mxcfb.h>


Is there something wrong?

Thanks!

[-- Attachment #1.2: Type: text/html, Size: 1223 bytes --]

[-- Attachment #2: alpha_ex1.c --]
[-- Type: text/x-csrc, Size: 6207 bytes --]

/*
* Copyright 2013 Freescale Semiconductor, Inc. All Rights Reserved.
*/

/*
* The code contained herein is licensed under the GNU Lesser General
* Public License. You may obtain a copy of the GNU Lesser General
* Public License Version 2.1 or later at the following locations:
*
* http://www.opensource.org/licenses/lgpl-license.html
* http://www.gnu.org/copyleft/lgpl.html
*/

#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <string.h>
#include <signal.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <linux/mxcfb.h>
#include <linux/ipu.h>

static unsigned int fmt_to_bpp(unsigned int pixelformat)
{
	unsigned int bpp;
 
        switch (pixelformat)
        {
                case IPU_PIX_FMT_RGB565:
               /*interleaved 422*/
                case IPU_PIX_FMT_YUYV:
                case IPU_PIX_FMT_UYVY:
                /*non-interleaved 422*/
                case IPU_PIX_FMT_YUV422P:
                case IPU_PIX_FMT_YVU422P:
                        bpp = 16;
                        break;
                case IPU_PIX_FMT_BGR24:
                case IPU_PIX_FMT_RGB24:
                case IPU_PIX_FMT_YUV444:
                case IPU_PIX_FMT_YUV444P:
                        bpp = 24;
                        break;
                case IPU_PIX_FMT_BGR32:
                case IPU_PIX_FMT_BGRA32:
                case IPU_PIX_FMT_RGB32:
                case IPU_PIX_FMT_RGBA32:
                case IPU_PIX_FMT_ABGR32:
                        bpp = 32;
                        break;
                /*non-interleaved 420*/
                case IPU_PIX_FMT_YUV420P:
                case IPU_PIX_FMT_YVU420P:
                case IPU_PIX_FMT_YUV420P2:
                case IPU_PIX_FMT_NV12:
    case IPU_PIX_FMT_TILED_NV12:
                        bpp = 12;
                        break;
                default:
                        bpp = 8;
                        break;
        }
        return bpp;
}

int main (int argc, char *argv[])
{
	struct ipu_task task;
	struct timeval begin, end;
	struct fb_var_screeninfo fb_var;
	struct fb_fix_screeninfo fb_fix;
	dma_addr_t outpaddr;

	int sec, usec, run_time;
	int fd_ipu, fd_fb, isize, ovsize, osize;
	int ret, i;
 
	void *inbuf = NULL;
	void *ovbuf = NULL;
	void *outbuf = NULL;

	// Clear &task	
	memset(&task, 0, sizeof(task));
 
	// Input image size and format
	task.input.width    = 1024;
	task.input.height   = 768;
	task.input.format   = v4l2_fourcc('R', 'G', 'B', 'P');
 
	// Overlay image size and format
	task.overlay.width    = 1024;
	task.overlay.height   = 768;
	task.overlay.format   = v4l2_fourcc('R', 'G', 'B', 'P');
	task.overlay_en = 1;
	task.overlay.alpha.mode = 0; //0 - Global alpha blending
	task.overlay.alpha.gvalue = 0;

	// Output image size and format
	task.output.width   = 1024;
	task.output.height  = 768;
	task.output.format  = v4l2_fourcc('R', 'G', 'B', 'P');
 
	// Open IPU device
	fd_ipu = open("/dev/mxc_ipu", O_RDWR, 0);
	if (fd_ipu < 0) {
		printf("open ipu dev fail\n");
		ret = -1;
		goto done;
	}

	// Calculate input size from image dimensions and bits-per-pixel
	// according to format
	isize = task.input.paddr =
		task.input.width * task.input.height
		* fmt_to_bpp(task.input.format)/8;

	// Allocate contingous physical memory for input image
	// input.paddr contains the amount needed
	// this value will be replaced with physical address on success
	ret = ioctl(fd_ipu, IPU_ALLOC, &task.input.paddr);
	if (ret < 0) {
		printf("ioctl IPU_ALLOC fail: (errno = %d)\n", errno);
		goto done;
	}

	// Create memory map and obtain the allocated memory virtual address
	inbuf = mmap(0, isize, PROT_READ | PROT_WRITE,
		MAP_SHARED, fd_ipu, task.input.paddr);
	if (!inbuf) {
		printf("mmap fail\n");
		ret = -1;
		goto done;
	}

	// Fill input buffer with white color
	memset(inbuf, 0xff, isize);

	// Calculate the overlay size 
	ovsize = task.overlay.paddr =
		task.overlay.width * task.overlay.height
		* fmt_to_bpp(task.overlay.format)/8;

	// Allocate contiguous  physical memory for overlay buffer
	ret = ioctl(fd_ipu, IPU_ALLOC, &task.overlay.paddr);
	if (ret < 0) {
		printf("ioctl IPU_ALLOC fail\n");
		goto done;
	}

	// Map the overlay buffer
	ovbuf = mmap(0, ovsize, PROT_READ | PROT_WRITE,
			MAP_SHARED, fd_ipu, task.overlay.paddr);
	if (!ovbuf) {
		printf("mmap fail\n");
		ret = -1;
		goto done;
	}

	// Fill overlay buffer with 4 color strips
	memset(ovbuf, 0x2222, ovsize/4);
	memset(ovbuf+ovsize/4, 0x6666, ovsize/4);
	memset(ovbuf+ovsize/2, 0xaaaa, ovsize/4);
	memset(ovbuf+ovsize*3/4, 0xdddd, ovsize/4);

	// Open Framebuffer and gets its address
	if ((fd_fb = open("/dev/fb0", O_RDWR, 0)) < 0) {
		printf("Unable to open /dev/fb0\n");
		ret = -1;
		goto done;
	}

	if ( ioctl(fd_fb, FBIOGET_FSCREENINFO, &fb_fix) < 0) {
		printf("Get FB fix info failed!\n");
		ret = -1;
		goto done;
	}

	ioctl(fd_fb, FBIOGET_FSCREENINFO, &fb_fix);

	// Set IPU output address as framebuffer address
	outpaddr = fb_fix.smem_start;	
	task.output.paddr = outpaddr;

	// Create memory map for output image
	outbuf = mmap(0, osize, PROT_READ | PROT_WRITE,
	MAP_SHARED, fd_ipu, task.output.paddr);
	if (!outbuf) {
		printf("mmap fail\n");
		ret = -1;
		goto done;
	}

	for (i=0; i < 256 ; i++) {

		task.overlay.alpha.gvalue = i;
		printf("Global Alpha Value = %d\n", i);

		gettimeofday(&begin, NULL);
	
		// Perform combining 
		ret = ioctl(fd_ipu, IPU_QUEUE_TASK, &task);
		if (ret < 0) {
			printf("ioct IPU_QUEUE_TASK fail %x\n", ret);
			goto done;
		}
	 
		gettimeofday(&end, NULL);
		sec = end.tv_sec - begin.tv_sec;
		usec = end.tv_usec - begin.tv_usec;
		if (usec < 0) {
			sec--;
			usec = usec + 1000000;
		}
		run_time = (sec * 1000000) + usec;
	
	  	printf("Resize time: %d usecs\n", run_time);
		usleep(100000);
	}
 
done:
	if (outbuf)
		munmap(outbuf, osize);
	if (task.output.paddr)
		ioctl(fd_ipu, IPU_FREE, &task.output.paddr);
	if (inbuf)
		munmap(inbuf, isize);
	if (ovbuf)
		munmap(ovbuf, isize);
	if (task.input.paddr)
		ioctl(fd_ipu, IPU_FREE, &task.input.paddr);
	if (fd_ipu)
		close(fd_ipu);
	if (fd_fb)
		close(fd_fb);

	return ret;
}


[-- Attachment #3: alpha_ex1.in --]
[-- Type: application/octet-stream, Size: 113 bytes --]

## SECTION=project_specific

config ALPHA_EX1
	tristate
	prompt "alpha_ex1"
	select KERNEL_HEADER
	help
	  FIXME

[-- Attachment #4: alpha_ex1.make --]
[-- Type: application/octet-stream, Size: 2932 bytes --]

# -*-makefile-*-
#
# Copyright (C) 2017 by <>AV
#
# See CREDITS for details about who has contributed to this project.
#
# For further information about the PTXdist project and license conditions
# see the README file.
#

#
# We provide this package
#
PACKAGES-$(PTXCONF_ALPHA_EX1) += alpha_ex1

#
# Paths and names
#
ALPHA_EX1_VERSION	:= 1
ALPHA_EX1_MD5		:=
ALPHA_EX1		:= alpha_ex1-$(ALPHA_EX1_VERSION)
ALPHA_EX1_URL		:= file://local_src/alpha_ex1
ALPHA_EX1_DIR		:= $(BUILDDIR)/$(ALPHA_EX1)
ALPHA_EX1_LICENSE	:= unknown

# ----------------------------------------------------------------------------
# Extract
# ----------------------------------------------------------------------------

#$(STATEDIR)/alpha_ex1.extract:
#	@$(call targetinfo)
#	@$(call clean, $(ALPHA_EX1_DIR))
#	@$(call extract, ALPHA_EX1)
#	@$(call patchin, ALPHA_EX1)
#	@$(call touch)

# ----------------------------------------------------------------------------
# Prepare
# ----------------------------------------------------------------------------

#ALPHA_EX1_PATH	:= PATH=$(CROSS_PATH)
ALPHA_EX1_CONF_TOOL	:= NO
ALPHA_EX1_MAKE_ENV	:= $(CROSS_ENV) \
CFLAGS="-I$(KERNEL_HEADERS_INCLUDE_DIR)"

#$(STATEDIR)/alpha_ex1.prepare:
#	@$(call targetinfo)
#	@$(call world/prepare, ALPHA_EX1)
#	@$(call touch)

# ----------------------------------------------------------------------------
# Compile
# ----------------------------------------------------------------------------

#$(STATEDIR)/alpha_ex1.compile:
#	@$(call targetinfo)
#	@$(call world/compile, ALPHA_EX1)
#	@$(call touch)

# ----------------------------------------------------------------------------
# Install
# ----------------------------------------------------------------------------

#$(STATEDIR)/alpha_ex1.install:
#	@$(call targetinfo)
#	@$(call world/install, ALPHA_EX1)
#	@$(call touch)

# ----------------------------------------------------------------------------
# Target-Install
# ----------------------------------------------------------------------------

$(STATEDIR)/alpha_ex1.targetinstall:
	@$(call targetinfo)

	@$(call install_init, alpha_ex1)
	@$(call install_fixup, alpha_ex1,PRIORITY,optional)
	@$(call install_fixup, alpha_ex1,SECTION,base)
	@$(call install_fixup, alpha_ex1,AUTHOR,"<>AV")
	@$(call install_fixup, alpha_ex1,DESCRIPTION,missing)

#
# TODO: Add here all files that should be copied to the target
# Note: Add everything before(!) call to macro install_finish
#
	@$(call install_copy, alpha_ex1, 0, 0, 0755, $(ALPHA_EX1_DIR)/alpha_ex1, /usr/bin/alpha_ex1)

	@$(call install_finish, alpha_ex1)

	@$(call touch)

# ----------------------------------------------------------------------------
# Clean
# ----------------------------------------------------------------------------

$(STATEDIR)/alpha_ex1.clean:
	@$(call targetinfo)
	@-cd $(ALPHA_EX1_DIR) && \
		$(ALPHA_EX1_ENV) $(ALPHA_EX1_PATH) $(MAKE) clean
	@$(call clean_pkg, ALPHA_EX1)

# vim: syntax=make

[-- Attachment #5: Makefile --]
[-- Type: application/octet-stream, Size: 201 bytes --]

all: ipu-examples

ipu-examples: alpha_ex1.c
	$(CC) -g -O0 -o alpha_ex1 alpha_ex1.c -I$(KERNEL_HEADERS_INCLUDE_DIR) \
	-I$(KERNEL_HEADERS_INCLUDE_DIR)/uapi

clean:
	-rm alpha_ex1

.PHONY: all clean

	

[-- Attachment #6: Type: text/plain, Size: 91 bytes --]

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-01-31 10:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-31  9:27 [ptxdist] kernel headers in ptxdist Alejandro Vázquez
2017-01-31  9:49 ` Juergen Borleis
2017-01-31 10:36   ` Alejandro Vázquez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox