tegra: Add PRIME support helpers
PATCH v2 6/25 tegra: Add PRIME support helpers
From: Thierry Reding <[email protected]>
These helpers facilitate exporting and importing buffer objects to and from PRIME file descriptors.
---
Changes in v3:
- add drm_public annotations
--- tegra/tegra-symbols.txt | 2 ++ tegra/tegra.c | 61 +++++++++++++++++++++++++++++++++++++++++ tegra/tegra.h | 4 +++ 3 files changed, 67 insertions(+)
tegra/tegra-symbols.txt +2 -0
@@ -1,5 +1,7 @@ +drm_tegra_bo_export drm_tegra_bo_get_handle drm_tegra_bo_get_name +drm_tegra_bo_import drm_tegra_bo_map drm_tegra_bo_new drm_tegra_bo_open
tegra/tegra.c +61 -0
64 lines not on this page · raw message
tegra/tegra.h +4 -0
@@ -48,4 +48,8 @@ int drm_tegra_bo_get_name(struct drm_tegra_bo *bo, uint32_t *name);int drm_tegra_bo_open (struct drm_tegra *drm,uint32_t name,uint32_t flags,struct drm_tegra_bo **bop); +int drm_tegra_bo_export (struct drm_tegra_bo *bo,uint32_t flags); +int drm_tegra_bo_import (struct drm_tegra *drm,int fd, +struct drm_tegra_bo **bop); +#endif /* __DRM_TEGRA_H__ */
Signature · 1 line
2.35.1
PATCH v2 7/25 tegra: Make API more consistent
From: Thierry Reding <[email protected]>
Most functions in libdrm_tegra take as first parameter the object that they operate on. Make the device and buffer object creation functions follow the same scheme.
--- tegra/tegra.c | 13 +++++++------ tegra/tegra.h | 10 +++++----- tests/tegra/openclose.c | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-)
tegra/tegra.c +7 -6
@@ -66,7 +66,7 @@ static int drm_tegra_wrap(struct drm_tegra **drmp, int fd, bool close)return 0 ; } -drm_public int drm_tegra_new(struct drm_tegra **drmp, int fd) +drm_public int drm_tegra_new(int fd, struct drm_tegra **drmp) {bool supported = false;drmVersionPtr version;
@@ -118,8 +118,8 @@ static struct drm_tegra_bo *drm_tegra_bo_alloc(struct drm_tegra *drm, } drm_public int -drm_tegra_bo_new (struct drm_tegra_bo **bop,struct drm_tegra *drm, -uint32_t flags,uint32_t size) +drm_tegra_bo_new (struct drm_tegra *drm,uint32_t flags,uint32_t size, +struct drm_tegra_bo **bop) {struct drm_tegra_gem_create args;struct drm_tegra_bo *bo;
@@ -152,8 +152,8 @@ drm_tegra_bo_new(struct drm_tegra_bo **bop, struct drm_tegra *drm, } drm_public int -drm_tegra_bo_wrap (struct drm_tegra_bo **bop,struct drm_tegra *drm, -uint32_t handle,uint32_t flags,uint32_t size) +drm_tegra_bo_wrap (struct drm_tegra *drm,uint32_t handle,uint32_t flags, +uint32_t size,struct drm_tegra_bo **bop) {struct drm_tegra_bo *bo;
@@ -183,7 +183,8 @@ drm_public void drm_tegra_bo_unref(struct drm_tegra_bo *bo)drm_tegra_bo_free (bo); } -drm_public int drm_tegra_bo_get_handle(struct drm_tegra_bo *bo, uint32_t *handle) +drm_public int +drm_tegra_bo_get_handle (struct drm_tegra_bo *bo,uint32_t *handle) {if (!bo || !handle)return -EINVAL ;
tegra/tegra.h +5 -5
@@ -31,13 +31,13 @@struct drm_tegra_bo ;struct drm_tegra ; -int drm_tegra_new (struct drm_tegra **drmp,int fd); +int drm_tegra_new (int fd,struct drm_tegra **drmp);void drm_tegra_close (struct drm_tegra *drm); -int drm_tegra_bo_new (struct drm_tegra_bo **bop,struct drm_tegra *drm, -uint32_t flags,uint32_t size); -int drm_tegra_bo_wrap (struct drm_tegra_bo **bop,struct drm_tegra *drm, -uint32_t handle,uint32_t flags,uint32_t size); +int drm_tegra_bo_new (struct drm_tegra *drm,uint32_t flags,uint32_t size, +struct drm_tegra_bo **bop); +int drm_tegra_bo_wrap (struct drm_tegra *drm,uint32_t handle,uint32_t flags, +uint32_t size,struct drm_tegra_bo **bop);struct drm_tegra_bo *drm_tegra_bo_ref (struct drm_tegra_bo *bo);void drm_tegra_bo_unref (struct drm_tegra_bo *bo);int drm_tegra_bo_get_handle (struct drm_tegra_bo *bo,uint32_t *handle);
tests/tegra/openclose.c +1 -1
@@ -56,7 +56,7 @@ int main(int argc, char *argv[])drmFreeVersion (version); } - err =drm_tegra_new (&tegra, fd); + err =drm_tegra_new (fd, &tegra);if (err <0 )return 1 ;
Signature · 1 line
2.35.1
Re: [PATCH libdrm v2 07/25] tegra: Make API more consistent
17.02.2022 22:19, Thierry Reding пишет:
Quoted 18 lines
From: Thierry Reding <[email protected]>
Most functions in
libdrm_tegratake as first parameter the object that they operate on. Make the device and buffer object creation functions follow the same scheme.Signed-off-by Thierry Reding <[email protected]>--- tegra/tegra.c | 13 +++++++------ tegra/tegra.h | 10 +++++----- tests/tegra/openclose.c | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-)tegra/tegra.c +0
-0
tegra/tegra.c static int drm_tegra_wrap(struct drm_tegra **drmp, int fd, bool close) · line 69
Quoted 5 lines
tegra/tegra.c +1
-1@@ -66,7 +66,7 @@ static int drm_tegra_wrap(struct drm_tegra **drmp, int fd, bool close)return 0 ; } -drm_public int drm_tegra_new(struct drm_tegra **drmp, int fd) +drm_public int drm_tegra_new(int fd, struct drm_tegra **drmp)
Does libdrm allow to break ABI?
PATCH v2 8/25 tegra: Install tegra-openclose test
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
Allow this simple test to be installed so that it can easily be run on a target device.
--- tests/tegra/.gitignore | 2 +- tests/tegra/meson.build | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-)
tests/tegra/.gitignore +1 -1
@@ -1 +1 @@ -openclose +tegra-openclose
tests/tegra/meson.build +5 -2
@@ -18,10 +18,13 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +inc_tegra = include_directories('../../tegra') + openclose = executable( - 'openclose', + 'tegra-openclose', files('openclose.c'), - include_directories : [inc_root, inc_drm, include_directories('../../tegra')], + include_directories : [inc_root, inc_drm, inc_tegra], c_args : libdrm_c_args, link_with : [libdrm, libdrm_tegra], + install : with_install_tests, )
Signature · 1 line
2.35.1
PATCH v2 9/25 tegra: Update for new UABI
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
This new UABI is a more modern version that works better with both old and recent chips.
--- include/drm/tegra_drm.h | 429 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 404 insertions(+), 25 deletions(-)
include/drm/tegra_drm.h +404 -25
@@ -1,27 +1,8 @@ -/* -* Copyright (c) 2012-2013, NVIDIA CORPORATION. All rights reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR -* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -* OTHER DEALINGS IN THE SOFTWARE. -*/ +/* SPDX-License-Identifier: MIT */ +/* Copyright (c) 2012-2020 NVIDIA Corporation */ -#ifndef _TEGRA_DRM_H_ -#define _TEGRA_DRM_H_ +#ifndef _UAPI_TEGRA_DRM_H_ +#define _UAPI_TEGRA_DRM_H_#include "drm.h"
@@ -29,6 +10,8 @@extern "C" {#endif +/* Tegra DRM legacy UAPI. Only enabled with STAGING */ +#define DRM_TEGRA_GEM_CREATE_TILED (1 << 0)#define DRM_TEGRA_GEM_CREATE_BOTTOM_UP (1 << 1)
@@ -649,8 +632,8 @@ struct drm_tegra_gem_get_flags {#define DRM_TEGRA_SYNCPT_READ 0x02#define DRM_TEGRA_SYNCPT_INCR 0x03#define DRM_TEGRA_SYNCPT_WAIT 0x04 -#define DRM_TEGRA_OPEN_CHANNEL 0x05 -#define DRM_TEGRA_CLOSE_CHANNEL 0x06 +#define DRM_TEGRA_OPEN_CHANNEL 0x05 +#define DRM_TEGRA_CLOSE_CHANNEL 0x06#define DRM_TEGRA_GET_SYNCPT 0x07#define DRM_TEGRA_SUBMIT 0x08#define DRM_TEGRA_GET_SYNCPT_BASE 0x09
@@ -674,6 +657,402 @@ struct drm_tegra_gem_get_flags {#define DRM_IOCTL_TEGRA_GEM_SET_FLAGS DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GEM_SET_FLAGS, struct drm_tegra_gem_set_flags)#define DRM_IOCTL_TEGRA_GEM_GET_FLAGS DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GEM_GET_FLAGS, struct drm_tegra_gem_get_flags) +/* New Tegra DRM UAPI */ + +/* +* Reported by the driver in the `capabilities` field. +* +* DRM_TEGRA_CHANNEL_CAP_CACHE_COHERENT: If set, the engine is cache coherent +* with regard to the system memory. +*/ +#define DRM_TEGRA_CHANNEL_CAP_CACHE_COHERENT (1 << 0) + +struct drm_tegra_channel_open { +/** +* @host1x_class: [in] +* +* Host1x class of the engine that will be programmed using this +* channel. +*/ +__u32 host1x_class; + +/** +* @flags: [in] +* +* Flags. +*/ +__u32 flags; + +/** +* @context: [out] +* +* Opaque identifier corresponding to the opened channel. +*/ +__u32 context; + +/** +* @version: [out] +* +* Version of the engine hardware. This can be used by userspace +* to determine how the engine needs to be programmed. +*/ +__u32 version; + +/** +* @capabilities: [out] +* +* Flags describing the hardware capabilities. +*/ +__u32 capabilities; +__u32 padding; +}; + +struct drm_tegra_channel_close { +/** +* @context: [in] +* +* Identifier of the channel to close. +*/ +__u32 context; +__u32 padding; +}; + +/* +* Mapping flags that can be used to influence how the mapping is created. +* +* DRM_TEGRA_CHANNEL_MAP_READ: create mapping that allows HW read access +* DRM_TEGRA_CHANNEL_MAP_WRITE: create mapping that allows HW write access +*/ +#define DRM_TEGRA_CHANNEL_MAP_READ (1 << 0) +#define DRM_TEGRA_CHANNEL_MAP_WRITE (1 << 1) +#define DRM_TEGRA_CHANNEL_MAP_READ_WRITE (DRM_TEGRA_CHANNEL_MAP_READ | \ + DRM_TEGRA_CHANNEL_MAP_WRITE) + +struct drm_tegra_channel_map { +/** +* @context: [in] +* +* Identifier of the channel to which make memory available for. +*/ +__u32 context; + +/** +* @handle: [in] +* +* GEM handle of the memory to map. +*/ +__u32 handle; + +/** +* @flags: [in] +* +* Flags. +*/ +__u32 flags; + +/** +* @mapping: [out] +* +* Identifier corresponding to the mapping, to be used for +* relocations or unmapping later. +*/ +__u32 mapping; +}; + +struct drm_tegra_channel_unmap { +/** +* @context: [in] +* +* Channel identifier of the channel to unmap memory from. +*/ +__u32 context; + +/** +* @mapping: [in] +* +* Mapping identifier of the memory mapping to unmap. +*/ +__u32 mapping; +}; + +/* Submission */ + +/** +* Specify that bit 39 of the patched-in address should be set to switch +* swizzling between Tegra and non-Tegra sector layout on systems that store +* surfaces in system memory in non-Tegra sector layout. +*/ +#define DRM_TEGRA_SUBMIT_RELOC_SECTOR_LAYOUT (1 << 0) + +struct drm_tegra_submit_buf { +/** +* @mapping: [in] +* +* Identifier of the mapping to use in the submission. +*/ +__u32 mapping; + +/** +* @flags: [in] +* +* Flags. +*/ +__u32 flags; + +/** +* Information for relocation patching. +*/ +struct { +/** +* @target_offset: [in] +* +* Offset from the start of the mapping of the data whose +* address is to be patched into the gather. +*/ +__u64 target_offset; + +/** +* @gather_offset_words: [in] +* +* Offset in words from the start of the gather data to +* where the address should be patched into. +*/ +__u32 gather_offset_words; + +/** +* @shift: [in] +* +* Number of bits the address should be shifted right before +* patching in. +*/ +__u32 shift; + } reloc; +}; + +/** +* Execute `words` words of Host1x opcodes specified in the `gather_data_ptr` +* buffer. Each GATHER_UPTR command uses successive words from the buffer. +*/ +#define DRM_TEGRA_SUBMIT_CMD_GATHER_UPTR 0 +/** +* Wait for a syncpoint to reach a value before continuing with further +* commands. +*/ +#define DRM_TEGRA_SUBMIT_CMD_WAIT_SYNCPT 1 +/** +* Wait for a syncpoint to reach a value before continuing with further +* commands. The threshold is calculated relative to the start of the job. +*/ +#define DRM_TEGRA_SUBMIT_CMD_WAIT_SYNCPT_RELATIVE 2 + +struct drm_tegra_submit_cmd_gather_uptr { +__u32 words; +__u32 reserved[3 ]; +}; + +struct drm_tegra_submit_cmd_wait_syncpt { +__u32 id; +__u32 value; +__u32 reserved[2 ]; +}; + +struct drm_tegra_submit_cmd { +/** +* @type: [in] +* +* Command type to execute. One of the DRM_TEGRA_SUBMIT_CMD* +* defines. +*/ +__u32 type; + +/** +* @flags: [in] +* +* Flags. +*/ +__u32 flags; + +union { +struct drm_tegra_submit_cmd_gather_uptr gather_uptr; +struct drm_tegra_submit_cmd_wait_syncpt wait_syncpt; +__u32 reserved[4 ]; + }; +}; + +struct drm_tegra_submit_syncpt { +/** +* @id: [in] +* +* ID of the syncpoint that the job will increment. +*/ +__u32 id; + +/** +* @flags: [in] +* +* Flags. +*/ +__u32 flags; + +/** +* @increments: [in] +* +* Number of times the job will increment this syncpoint. +*/ +__u32 increments; + +/** +* @value: [out] +* +* Value the syncpoint will have once the job has completed all +* its specified syncpoint increments. +* +* Note that the kernel may increment the syncpoint before or after +* the job. These increments are not reflected in this field. +* +* If the job hangs or times out, not all of the increments may +* get executed. +*/ +__u32 value; +}; + +struct drm_tegra_channel_submit { +/** +* @context: [in] +* +* Identifier of the channel to submit this job to. +*/ +__u32 context; + +/** +* @num_bufs: [in] +* +* Number of elements in the `bufs_ptr` array. +*/ +__u32 num_bufs; + +/** +* @num_cmds: [in] +* +* Number of elements in the `cmds_ptr` array. +*/ +__u32 num_cmds; + +/** +* @gather_data_words: [in] +* +* Number of 32-bit words in the `gather_data_ptr` array. +*/ +__u32 gather_data_words; + +/** +* @bufs_ptr: [in] +* +* Pointer to an array of drm_tegra_submit_buf structures. +*/ +__u64 bufs_ptr; + +/** +* @cmds_ptr: [in] +* +* Pointer to an array of drm_tegra_submit_cmd structures. +*/ +__u64 cmds_ptr; + +/** +* @gather_data_ptr: [in] +* +* Pointer to an array of Host1x opcodes to be used by GATHER_UPTR +* commands. +*/ +__u64 gather_data_ptr; + +/** +* @syncobj_in: [in] +* +* Handle for DRM syncobj that will be waited before submission. +* Ignored if zero. +*/ +__u32 syncobj_in; + +/** +* @syncobj_out: [in] +* +* Handle for DRM syncobj that will have its fence replaced with +* the job's completion fence. Ignored if zero. +*/ +__u32 syncobj_out; + +/** +* @syncpt_incr: [in,out] +* +* Information about the syncpoint the job will increment. +*/ +struct drm_tegra_submit_syncpt syncpt; +}; + +struct drm_tegra_syncpoint_allocate { +/** +* @id: [out] +* +* ID of allocated syncpoint. +*/ +__u32 id; +__u32 padding; +}; + +struct drm_tegra_syncpoint_free { +/** +* @id: [in] +* +* ID of syncpoint to free. +*/ +__u32 id; +__u32 padding; +}; + +struct drm_tegra_syncpoint_wait { +/** +* @timeout: [in] +* +* Absolute timestamp at which the wait will time out. +*/ +__s64 timeout_ns; + +/** +* @id: [in] +* +* ID of syncpoint to wait on. +*/ +__u32 id; + +/** +* @threshold: [in] +* +* Threshold to wait for. +*/ +__u32 threshold; + +/** +* @value: [out] +* +* Value of the syncpoint upon wait completion. +*/ +__u32 value; + +__u32 padding; +}; + +#define DRM_IOCTL_TEGRA_CHANNEL_OPEN DRM_IOWR(DRM_COMMAND_BASE + 0x10, struct drm_tegra_channel_open) +#define DRM_IOCTL_TEGRA_CHANNEL_CLOSE DRM_IOWR(DRM_COMMAND_BASE + 0x11, struct drm_tegra_channel_close) +#define DRM_IOCTL_TEGRA_CHANNEL_MAP DRM_IOWR(DRM_COMMAND_BASE + 0x12, struct drm_tegra_channel_map) +#define DRM_IOCTL_TEGRA_CHANNEL_UNMAP DRM_IOWR(DRM_COMMAND_BASE + 0x13, struct drm_tegra_channel_unmap) +#define DRM_IOCTL_TEGRA_CHANNEL_SUBMIT DRM_IOWR(DRM_COMMAND_BASE + 0x14, struct drm_tegra_channel_submit) + +#define DRM_IOCTL_TEGRA_SYNCPOINT_ALLOCATE DRM_IOWR(DRM_COMMAND_BASE + 0x20, struct drm_tegra_syncpoint_allocate) +#define DRM_IOCTL_TEGRA_SYNCPOINT_FREE DRM_IOWR(DRM_COMMAND_BASE + 0x21, struct drm_tegra_syncpoint_free) +#define DRM_IOCTL_TEGRA_SYNCPOINT_WAIT DRM_IOWR(DRM_COMMAND_BASE + 0x22, struct drm_tegra_syncpoint_wait) +#if defined(__cplusplus) }#endif
Signature · 1 line
2.35.1
PATCH v2 10/25 tegra: Include private.h in list of source files
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
This makes sure that the proper dependencies are created and that the file is distributed.
--- tegra/meson.build | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
tegra/meson.build +6 -1
@@ -20,7 +20,12 @@ libdrm_tegra = library( 'drm_tegra', - [files('tegra.c'), config_file], + [ + files( + 'private.h', 'tegra.c' + ), + config_file + ], include_directories : [inc_root, inc_drm], link_with : libdrm, dependencies : [dep_pthread_stubs, dep_atomic_ops],
Signature · 1 line
2.35.1
PATCH v2 11/25 tegra: Add channel APIs
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
These new functions can be used to open a channel to a given engine, map and unmap buffer objects to that channel, and close the channel.
--- tegra/channel.c | 195 ++++++++++++++++++++++++++++++++++++++++ tegra/meson.build | 2 +- tegra/private.h | 24 +++++ tegra/tegra-symbols.txt | 5 ++ tegra/tegra.h | 22 +++++ 5 files changed, 247 insertions(+), 1 deletion(-) create mode 100644 tegra/channel.c
tegra/channel.c new file +195 -0
@@ -0,0 +1,195 @@ +/* +* Copyright © 2012, 2013 Thierry Reding +* Copyright © 2013 Erik Faye-Lund +* Copyright © 2014-2021 NVIDIA Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <errno.h> +#include <string.h> + +#include <sys/ioctl.h> + +#include "private.h" + +drm_public int +drm_tegra_channel_open (struct drm_tegra *drm, +enum drm_tegra_class client, +struct drm_tegra_channel **channelp) +{ +struct drm_tegra_channel_open args; +struct drm_tegra_channel *channel; +enum host1x_class class; +int err; + +switch (client) { +case DRM_TEGRA_HOST1X : + class =HOST1X_CLASS_HOST1X ; +break ; + +case DRM_TEGRA_GR2D : + class =HOST1X_CLASS_GR2D ; +break ; + +case DRM_TEGRA_GR3D : + class =HOST1X_CLASS_GR3D ; +break ; + +case DRM_TEGRA_VIC : + class =HOST1X_CLASS_VIC ; +break ; + +default : +return -EINVAL ; + } + + channel =calloc (1 ,sizeof (*channel)); +if (!channel) +return -ENOMEM ; + + channel->drm = drm; + +memset (&args,0 ,sizeof (args)); + args.host1x_class = class; + + err =ioctl (drm->fd,DRM_IOCTL_TEGRA_CHANNEL_OPEN , &args); +if (err <0 ) { +free (channel); +return -errno; + } + + channel->context = args.context; + channel->version = args.version; + channel->capabilities = args.capabilities; + channel->class = class; + +switch (channel->version) { +case 0x20 : +case 0x30 : +case 0x35 : +case 0x40 : +case 0x21 : + channel->cond_shift =8 ; +break ; + +case 0x18 : +case 0x19 : + channel->cond_shift =10 ; +break ; + +default : +return -ENOTSUP ; + } + + *channelp = channel; + +return 0 ; +} + +drm_public int drm_tegra_channel_close(struct drm_tegra_channel *channel) +{ +struct drm_tegra_channel_close args; +struct drm_tegra *drm; +int err; + +if (!channel) +return -EINVAL ; + + drm = channel->drm; + +memset (&args,0 ,sizeof (args)); + args.context = channel->context; + + err =ioctl (drm->fd,DRM_IOCTL_TEGRA_CHANNEL_CLOSE , &args); +if (err <0 ) +return -errno; + +free (channel); + +return 0 ; +} + +drm_public unsigned int +drm_tegra_channel_get_version (struct drm_tegra_channel *channel) +{ +return channel->version; +} + +drm_public int +drm_tegra_channel_map (struct drm_tegra_channel *channel, +struct drm_tegra_bo *bo,uint32_t flags, +struct drm_tegra_mapping **mapp) +{ +struct drm_tegra *drm = channel->drm; +struct drm_tegra_channel_map args; +struct drm_tegra_mapping *map; +int err; + +if (!drm || !bo || !mapp) +return -EINVAL ; + + map =calloc (1 ,sizeof (*map)); +if (!map) +return -ENOMEM ; + +memset (&args,0 ,sizeof (args)); + args.context = channel->context; + args.handle = bo->handle; + args.flags = flags; + + err =ioctl (drm->fd,DRM_IOCTL_TEGRA_CHANNEL_MAP , &args); +if (err <0 ) { +free (map); +return -errno; + } + + map->channel = channel; + map->id = args.mapping; + *mapp = map; + +return 0 ; +} + +drm_public int +drm_tegra_channel_unmap (struct drm_tegra_mapping *map) +{ +struct drm_tegra_channel *channel = map->channel; +struct drm_tegra *drm = channel->drm; +struct drm_tegra_channel_unmap args; +int err; + +if (!channel || !map) +return -EINVAL ; + +memset (&args,0 ,sizeof (args)); + args.context = channel->context; + args.mapping = map->id; + + err =ioctl (drm->fd,DRM_IOCTL_TEGRA_CHANNEL_UNMAP , &args); +if (err <0 ) +return -errno; + +free (map); +return 0 ; +}
tegra/meson.build +1 -1
@@ -22,7 +22,7 @@ libdrm_tegra = library( 'drm_tegra', [ files( - 'private.h', 'tegra.c' + 'channel.c', 'private.h', 'tegra.c' ), config_file ],
tegra/private.h +24 -0
@@ -31,8 +31,17 @@#include <libdrm_macros.h> #include <xf86atomic.h> +#include "tegra_drm.h" #include "tegra.h" +enum host1x_class { +HOST1X_CLASS_HOST1X =0x01 , +HOST1X_CLASS_GR2D =0x51 , +HOST1X_CLASS_GR2D_SB =0x52 , +HOST1X_CLASS_VIC =0x5d , +HOST1X_CLASS_GR3D =0x60 , +}; +struct drm_tegra {bool close;int fd;
@@ -48,4 +57,19 @@ struct drm_tegra_bo { void *map; }; +struct drm_tegra_channel { +struct drm_tegra *drm; +enum host1x_class class; +uint32_t capabilities; +unsigned int version; +uint64_t context; + +unsigned int cond_shift; +}; + +struct drm_tegra_mapping { +struct drm_tegra_channel *channel; +uint32_t id; +}; +#endif /* __DRM_TEGRA_PRIVATE_H__ */
tegra/tegra-symbols.txt +5 -0
@@ -9,5 +9,10 @@ drm_tegra_bo_ref drm_tegra_bo_unmap drm_tegra_bo_unref drm_tegra_bo_wrap +drm_tegra_channel_close +drm_tegra_channel_get_version +drm_tegra_channel_map +drm_tegra_channel_open +drm_tegra_channel_unmap drm_tegra_close drm_tegra_new
tegra/tegra.h +22 -0
@@ -28,6 +28,15 @@#include <stdint.h> #include <stdlib.h> +#include <tegra_drm.h> + +enum drm_tegra_class { +DRM_TEGRA_HOST1X , +DRM_TEGRA_GR2D , +DRM_TEGRA_GR3D , +DRM_TEGRA_VIC , +}; +struct drm_tegra_bo ;struct drm_tegra ;
@@ -52,4 +61,17 @@ int drm_tegra_bo_export(struct drm_tegra_bo *bo, uint32_t flags);int drm_tegra_bo_import (struct drm_tegra *drm,int fd,struct drm_tegra_bo **bop); +struct drm_tegra_channel ; +struct drm_tegra_mapping ; + +int drm_tegra_channel_open (struct drm_tegra *drm, +enum drm_tegra_class client, +struct drm_tegra_channel **channelp); +int drm_tegra_channel_close (struct drm_tegra_channel *channel); +unsigned int drm_tegra_channel_get_version (struct drm_tegra_channel *channel); +int drm_tegra_channel_map (struct drm_tegra_channel *channel, +struct drm_tegra_bo *bo,uint32_t flags, +struct drm_tegra_mapping **mapp); +int drm_tegra_channel_unmap (struct drm_tegra_mapping *map); +#endif /* __DRM_TEGRA_H__ */
Signature · 1 line
2.35.1
PATCH v2 12/25 tegra: Add job and push buffer APIs
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
These new functions can be used to create a job on a given channel, add commands to the job using its push buffer and submit the job.
--- tegra/job.c | 164 ++++++++++++++++++++++++++++++++++++++++ tegra/meson.build | 2 +- tegra/private.h | 32 ++++++++ tegra/pushbuf.c | 136 +++++++++++++++++++++++++++++++++ tegra/tegra-symbols.txt | 7 ++ tegra/tegra.h | 34 +++++++++ 6 files changed, 374 insertions(+), 1 deletion(-) create mode 100644 tegra/job.c create mode 100644 tegra/pushbuf.c
tegra/job.c new file +164 -0
@@ -0,0 +1,164 @@ +/* +* Copyright © 2012, 2013 Thierry Reding +* Copyright © 2013 Erik Faye-Lund +* Copyright © 2014 NVIDIA Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <errno.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> +#include <unistd.h> + +#include <sys/ioctl.h> +#include <sys/poll.h> + +#include "private.h" + +struct drm_tegra_submit_cmd * +drm_tegra_job_add_command (struct drm_tegra_job *job,uint32_t type, +uint32_t flags) +{ +struct drm_tegra_submit_cmd *commands, *command; +size_t size; + + size = (job->num_commands +1 ) *sizeof (*commands); + + commands =realloc (job->commands, size); +if (!commands) +return NULL ; + + command = &commands[job->num_commands]; +memset (command,0 ,sizeof (*command)); + command->type = type; + command->flags = flags; + + job->commands = commands; + job->num_commands++; + +return command; +} + +drm_public int +drm_tegra_job_new (struct drm_tegra_channel *channel, +struct drm_tegra_job **jobp) +{ +struct drm_tegra_job *job; + + job =calloc (1 ,sizeof (*job)); +if (!job) +return -ENOMEM ; + + job->page_size =sysconf (_SC_PAGESIZE); + job->channel = channel; + + *jobp = job; + +return 0 ; +} + +drm_public int drm_tegra_job_free(struct drm_tegra_job *job) +{ +if (!job) +return -EINVAL ; + +if (job->pushbuf) +drm_tegra_pushbuf_free (job->pushbuf); + +if (job->commands) +free (job->commands); + +if (job->buffers) +free (job->buffers); + +free (job); + +return 0 ; +} + +drm_public int +drm_tegra_job_get_pushbuf (struct drm_tegra_job *job, +struct drm_tegra_pushbuf **pushbufp) +{ +struct drm_tegra_pushbuf *pushbuf; + +if (!job->pushbuf) { + pushbuf =calloc (1 ,sizeof (*pushbuf)); +if (!pushbuf) +return -ENOMEM ; + + pushbuf->job = job; + + pushbuf->start =calloc (1 , job->page_size); +if (!pushbuf->start) { +free (pushbuf); +return -ENOMEM ; + } + + pushbuf->end = pushbuf->start + job->page_size /4 ; + pushbuf->ptr = pushbuf->start; + + job->pushbuf = pushbuf; + } + + *pushbufp = job->pushbuf; + +return 0 ; +} + +drm_public int +drm_tegra_job_submit (struct drm_tegra_job *job,struct drm_tegra_fence *fence) +{ +struct drm_tegra_channel *channel = job->channel; +struct drm_tegra *drm = channel->drm; +struct drm_tegra_channel_submit args; +int err; + +memset (&args,0 ,sizeof (args)); + args.context = channel->context; + args.num_bufs = job->num_buffers; + args.num_cmds = job->num_commands; + args.gather_data_words = job->pushbuf->ptr - job->pushbuf->start; + args.syncpt.id = job->syncpt.id; + args.syncpt.increments = job->syncpt.increments; + + args.bufs_ptr = (uintptr_t )job->buffers; + args.cmds_ptr = (uintptr_t )job->commands; + args.gather_data_ptr = (uintptr_t )job->pushbuf->start; + + err =ioctl (drm->fd,DRM_IOCTL_TEGRA_CHANNEL_SUBMIT , &args); +if (err <0 ) +return -errno; + + job->syncpt.fence = args.syncpt.value; + +if (fence) { + fence->drm = drm; + fence->syncpt = job->syncpt.id; + fence->value = job->syncpt.fence; + } + +return 0 ; +}
tegra/meson.build +1 -1
@@ -22,7 +22,7 @@ libdrm_tegra = library( 'drm_tegra', [ files( - 'channel.c', 'private.h', 'tegra.c' + 'channel.c', 'job.c', 'private.h', 'pushbuf.c', 'tegra.c' ), config_file ],
tegra/private.h +32 -0
@@ -72,4 +72,36 @@ struct drm_tegra_mapping { uint32_t id; }; +struct drm_tegra_pushbuf { +struct drm_tegra_job *job; + +uint32_t *start; +uint32_t *end; +uint32_t *ptr; +}; + +void drm_tegra_pushbuf_free (struct drm_tegra_pushbuf *pushbuf); + +struct drm_tegra_job { +struct drm_tegra_channel *channel; +struct drm_tegra_pushbuf *pushbuf; +size_t page_size; + +struct drm_tegra_submit_cmd *commands; +unsigned int num_commands; + +struct drm_tegra_submit_buf *buffers; +unsigned int num_buffers; + +struct { +uint32_t id; +uint32_t increments; +uint32_t fence; + } syncpt; +}; + +struct drm_tegra_submit_cmd * +drm_tegra_job_add_command (struct drm_tegra_job *job,uint32_t type, +uint32_t flags); +#endif /* __DRM_TEGRA_PRIVATE_H__ */
tegra/pushbuf.c new file +136 -0
136 lines not on this page · raw message
tegra/tegra-symbols.txt +7 -0
@@ -15,4 +15,11 @@ drm_tegra_channel_map drm_tegra_channel_open drm_tegra_channel_unmap drm_tegra_close +drm_tegra_job_free +drm_tegra_job_get_pushbuf +drm_tegra_job_new +drm_tegra_job_submit drm_tegra_new +drm_tegra_pushbuf_begin +drm_tegra_pushbuf_end +drm_tegra_pushbuf_relocate
tegra/tegra.h +34 -0
@@ -63,6 +63,22 @@ int drm_tegra_bo_import(struct drm_tegra *drm, int fd,struct drm_tegra_channel ;struct drm_tegra_mapping ; +struct drm_tegra_pushbuf ; +struct drm_tegra_job ; + +enum drm_tegra_sync_cond { +DRM_TEGRA_SYNC_COND_IMMEDIATE , +DRM_TEGRA_SYNC_COND_OP_DONE , +DRM_TEGRA_SYNC_COND_RD_DONE , +DRM_TEGRA_SYNC_COND_WR_SAFE , +DRM_TEGRA_SYNC_COND_MAX , + }; + +struct drm_tegra_fence { +struct drm_tegra *drm; +uint32_t syncpt; +uint32_t value; +}; int drm_tegra_channel_open(struct drm_tegra *drm, enum drm_tegra_class client,
@@ -74,4 +90,22 @@ int drm_tegra_channel_map(struct drm_tegra_channel *channel, struct drm_tegra_mapping **mapp);int drm_tegra_channel_unmap (struct drm_tegra_mapping *map); +int drm_tegra_job_new (struct drm_tegra_channel *channel, +struct drm_tegra_job **jobp); +int drm_tegra_job_free (struct drm_tegra_job *job); +int drm_tegra_job_get_pushbuf (struct drm_tegra_job *job, +struct drm_tegra_pushbuf **pushbufp); +int drm_tegra_job_submit (struct drm_tegra_job *job, +struct drm_tegra_fence *fence); +int drm_tegra_job_wait (struct drm_tegra_job *job,unsigned long timeout); + +int drm_tegra_pushbuf_begin (struct drm_tegra_pushbuf *pushbuf, +unsigned int words,uint32_t **ptrp); +int drm_tegra_pushbuf_end (struct drm_tegra_pushbuf *pushbuf,uint32_t *ptr); +int drm_tegra_pushbuf_relocate (struct drm_tegra_pushbuf *pushbuf, +uint32_t **ptrp, +struct drm_tegra_mapping *target, +unsigned long offset,unsigned int shift, +uint32_t flags); +#endif /* __DRM_TEGRA_H__ */
Signature · 1 line
2.35.1
PATCH v2 13/25 tegra: Add syncpoint APIs
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
These new functions can be used to allocate and free syncpoints, as well as wait for a syncpoint threshold to be reached. Jobs can also be waited on if a syncpoint was attached to them.
--- tegra/job.c | 23 +++++++++ tegra/meson.build | 2 +- tegra/private.h | 5 ++ tegra/pushbuf.c | 48 +++++++++++++++++++ tegra/syncpt.c | 101 ++++++++++++++++++++++++++++++++++++++++ tegra/tegra-symbols.txt | 7 +++ tegra/tegra.h | 16 +++++++ 7 files changed, 201 insertions(+), 1 deletion(-) create mode 100644 tegra/syncpt.c
tegra/job.c +23 -0
@@ -162,3 +162,26 @@ drm_tegra_job_submit(struct drm_tegra_job *job, struct drm_tegra_fence *fence)return 0 ; } + +drm_public int +drm_tegra_job_wait (struct drm_tegra_job *job,unsigned long timeout) +{ +struct drm_tegra_channel *channel = job->channel; +struct drm_tegra *drm = channel->drm; +struct drm_tegra_syncpoint_wait args; +struct timespec ts; +int err; + +clock_gettime (CLOCK_MONOTONIC , &ts); + +memset (&args,0 ,sizeof (args)); + args.timeout_ns = ts.tv_sec *1000000000 + ts.tv_nsec + timeout; + args.id = job->syncpt.id; + args.threshold = job->syncpt.fence; + + err =ioctl (drm->fd,DRM_IOCTL_TEGRA_SYNCPOINT_WAIT , &args); +if (err <0 ) +return -errno; + +return 0 ; +}
tegra/meson.build +1 -1
@@ -22,7 +22,7 @@ libdrm_tegra = library( 'drm_tegra', [ files( - 'channel.c', 'job.c', 'private.h', 'pushbuf.c', 'tegra.c' + 'channel.c', 'job.c', 'private.h', 'pushbuf.c', 'syncpt.c', 'tegra.c' ), config_file ],
tegra/private.h +5 -0
@@ -104,4 +104,9 @@ struct drm_tegra_submit_cmd * drm_tegra_job_add_command(struct drm_tegra_job *job, uint32_t type, uint32_t flags); +struct drm_tegra_syncpoint { +struct drm_tegra *drm; +uint32_t id; +}; +#endif /* __DRM_TEGRA_PRIVATE_H__ */
tegra/pushbuf.c +48 -0
57 lines not on this page · raw message
tegra/syncpt.c new file +101 -0
101 lines not on this page · raw message
tegra/tegra-symbols.txt +7 -0
@@ -15,11 +15,18 @@ drm_tegra_channel_map drm_tegra_channel_open drm_tegra_channel_unmap drm_tegra_close +drm_tegra_fence_wait drm_tegra_job_free drm_tegra_job_get_pushbuf drm_tegra_job_new drm_tegra_job_submit +drm_tegra_job_wait drm_tegra_new drm_tegra_pushbuf_begin drm_tegra_pushbuf_end drm_tegra_pushbuf_relocate +drm_tegra_pushbuf_sync +drm_tegra_pushbuf_sync_cond +drm_tegra_pushbuf_wait +drm_tegra_syncpoint_free +drm_tegra_syncpoint_new
tegra/tegra.h +16 -0
@@ -65,6 +65,7 @@ struct drm_tegra_channel;struct drm_tegra_mapping ;struct drm_tegra_pushbuf ;struct drm_tegra_job ; +struct drm_tegra_syncpoint ;enum drm_tegra_sync_cond {DRM_TEGRA_SYNC_COND_IMMEDIATE ,
@@ -102,10 +103,25 @@ int drm_tegra_job_wait(struct drm_tegra_job *job, unsigned long timeout);int drm_tegra_pushbuf_begin (struct drm_tegra_pushbuf *pushbuf,unsigned int words,uint32_t **ptrp);int drm_tegra_pushbuf_end (struct drm_tegra_pushbuf *pushbuf,uint32_t *ptr); +int drm_tegra_pushbuf_wait (struct drm_tegra_pushbuf *pushbuf, +struct drm_tegra_syncpoint *syncpt, +uint32_t value);int drm_tegra_pushbuf_relocate (struct drm_tegra_pushbuf *pushbuf,uint32_t **ptrp,struct drm_tegra_mapping *target,unsigned long offset,unsigned int shift,uint32_t flags); +int drm_tegra_pushbuf_sync (struct drm_tegra_pushbuf *pushbuf, +struct drm_tegra_syncpoint *syncpt, +unsigned int count); +int drm_tegra_pushbuf_sync_cond (struct drm_tegra_pushbuf *pushbuf, +uint32_t **ptrp, +struct drm_tegra_syncpoint *syncpt, +enum drm_tegra_sync_cond cond); + +int drm_tegra_syncpoint_new (struct drm_tegra *drm, +struct drm_tegra_syncpoint **syncptp); +int drm_tegra_syncpoint_free (struct drm_tegra_syncpoint *syncpt); +int drm_tegra_fence_wait (struct drm_tegra_fence *fence,unsigned long timeout);#endif /* __DRM_TEGRA_H__ */
Signature · 1 line
2.35.1
PATCH v2 14/25 tests: tegra: Add helper library for tests
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
This library provides helpers for common functionality needed by test programs.
--- tests/tegra/drm-test.c | 248 ++++++++++++++++++++++++++++++++++++++++ tests/tegra/drm-test.h | 72 ++++++++++++ tests/tegra/meson.build | 7 ++ 3 files changed, 327 insertions(+) create mode 100644 tests/tegra/drm-test.c create mode 100644 tests/tegra/drm-test.h
tests/tegra/drm-test.c new file +248 -0
@@ -0,0 +1,248 @@ +/* +* Copyright © 2014 NVIDIA Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <errno.h> +#include <fcntl.h> +#include <stdbool.h> +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#include <sys/ioctl.h> + +#include "xf86drm.h" +#include "xf86drmMode.h" +#include "drm_fourcc.h" + +#include "drm-test.h" + +static int drm_screen_probe_connector (struct drm_screen *screen, +drmModeConnectorPtr connector) +{ +drmModeEncoderPtr encoder; +drmModeCrtcPtr crtc; +drmModeFBPtr fb; + + encoder =drmModeGetEncoder (screen->fd, connector->encoder_id); +if (!encoder) +return -ENODEV ; + + crtc =drmModeGetCrtc (screen->fd, encoder->crtc_id); +if (!crtc) { +drmModeFreeEncoder (encoder); +return -ENODEV ; + } + + screen->old_fb = crtc->buffer_id; + + fb =drmModeGetFB (screen->fd, crtc->buffer_id); +if (!fb) { +/* TODO: create new framebuffer */ +drmModeFreeEncoder (encoder); +drmModeFreeCrtc (crtc); +return -ENOSYS ; + } + + screen->connector = connector->connector_id; + screen->old_fb = crtc->buffer_id; + screen->crtc = encoder->crtc_id; +/* TODO: check crtc->mode_valid */ + screen->mode = crtc->mode; + + screen->width = fb->width; + screen->height = fb->height; + screen->pitch = fb->pitch; + screen->depth = fb->depth; + screen->bpp = fb->bpp; + +drmModeFreeEncoder (encoder); +drmModeFreeCrtc (crtc); +drmModeFreeFB (fb); + +return 0 ; +} + +int drm_screen_open (struct drm_screen **screenp,int fd) +{ +drmModeConnectorPtr connector; +struct drm_screen *screen; +bool found = false; +drmModeResPtr res; +unsigned int i; +int err; + +if (!screenp || fd <0 ) +return -EINVAL ; + + screen =calloc (1 ,sizeof (*screen)); +if (!screen) +return -ENOMEM ; + + screen->format =DRM_FORMAT_XRGB8888 ; + screen->fd = fd; + + res =drmModeGetResources (fd); +if (!res) { +free (screen); +return -ENOMEM ; + } + +for (i =0 ; i < (unsigned int )res->count_connectors; i++) { + connector =drmModeGetConnector (fd, res->connectors[i]); +if (!connector) +continue ; + +if (connector->connection !=DRM_MODE_CONNECTED ) { +drmModeFreeConnector (connector); +continue ; + } + + err =drm_screen_probe_connector (screen, connector); +if (err <0 ) { +drmModeFreeConnector (connector); +continue ; + } + +drmModeFreeConnector (connector); + found = true; +break ; + } + +drmModeFreeResources (res); + +if (!found) { +free (screen); +return -ENODEV ; + } + + *screenp = screen; + +return 0 ; +} + +int drm_screen_close (struct drm_screen *screen) +{ +int err; + + err =drmModeSetCrtc (screen->fd, screen->crtc, screen->old_fb,0 ,0 , + &screen->connector,1 , &screen->mode); +if (err <0 ) { +fprintf (stderr,"drmModeSetCrtc() failed: %m\n" ); +return -errno; + } + +free (screen); + +return 0 ; +} + +int drm_framebuffer_new (struct drm_framebuffer **fbp, +struct drm_screen *screen,uint32_t handle, +unsigned int width,unsigned int height, +unsigned int pitch,uint32_t format, +void *data) +{ +struct drm_framebuffer *fb; +uint32_t handles[4 ]; +uint32_t pitches[4 ]; +uint32_t offsets[4 ]; +int err; + + fb =calloc (1 ,sizeof (*fb)); +if (!fb) +return -ENOMEM ; + + fb->fd = screen->fd; + fb->width = width; + fb->height = height; + fb->pitch = pitch; + fb->format = format; + fb->data = data; + + handles[0 ] = handle; + pitches[0 ] = pitch; + offsets[0 ] =0 ; + + err =drmModeAddFB2 (screen->fd, width, height, format, handles, + pitches, offsets, &fb->handle,0 ); +if (err <0 ) +return -errno; + + *fbp = fb; + +return 0 ; +} + +int drm_framebuffer_free (struct drm_framebuffer *fb) +{ +int err; + + err =drmModeRmFB (fb->fd, fb->handle); +if (err <0 ) +return -errno; + +free (fb); + +return 0 ; +} + +int drm_screen_set_framebuffer (struct drm_screen *screen, +struct drm_framebuffer *fb) +{ +int err; + + err =drmModeSetCrtc (screen->fd, screen->crtc, fb->handle,0 ,0 , + &screen->connector,1 , &screen->mode); +if (err <0 ) +return -errno; + +return 0 ; +} + +int drm_open (const char *path) +{ +int fd, err; + + fd =open (path,O_RDWR ); +if (fd <0 ) +return -errno; + + err =drmSetMaster (fd); +if (err <0 ) { +close (fd); +return -errno; + } + +return fd; +} + +void drm_close (int fd) +{ +drmDropMaster (fd); +close (fd); +}
tests/tegra/drm-test.h new file +72 -0
72 lines not on this page · raw message
tests/tegra/meson.build +7 -0
@@ -20,6 +20,13 @@ inc_tegra = include_directories('../../tegra') +libdrm_test = static_library( + 'drm-test', + [files('drm-test.c', 'drm-test.h'), config_file ], + include_directories : [inc_root, inc_drm, inc_tegra], + link_with : libdrm, +) + openclose = executable( 'tegra-openclose', files('openclose.c'),
Signature · 1 line
2.35.1
PATCH v2 15/25 tests: tegra: Add gr2d-fill test
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
This test uses the IOCTLs for job submission and fences to fill a sub- region of the screen to a specific color using gr2d.
--- tests/tegra/.gitignore | 1 + tests/tegra/drm-test-tegra.c | 147 +++++++++++++++++++++++++++++++++++ tests/tegra/drm-test-tegra.h | 55 +++++++++++++ tests/tegra/gr2d-fill.c | 146 ++++++++++++++++++++++++++++++++++ tests/tegra/meson.build | 19 +++++ 5 files changed, 368 insertions(+) create mode 100644 tests/tegra/drm-test-tegra.c create mode 100644 tests/tegra/drm-test-tegra.h create mode 100644 tests/tegra/gr2d-fill.c
tests/tegra/.gitignore +1 -0
@@ -1 +1,2 @@ +tegra-gr2d-fill tegra-openclose
tests/tegra/drm-test-tegra.c new file +147 -0
147 lines not on this page · raw message
tests/tegra/drm-test-tegra.h new file +55 -0
55 lines not on this page · raw message
tests/tegra/gr2d-fill.c new file +146 -0
146 lines not on this page · raw message
tests/tegra/meson.build +19 -0
@@ -27,6 +27,16 @@ libdrm_test = static_library( link_with : libdrm, ) +libdrm_test_tegra = static_library( + 'drm-test-tegra', + [files( + 'drm-test-tegra.c', + 'drm-test-tegra.h', + ), config_file ], + include_directories : [inc_root, inc_drm, inc_tegra], + link_with : libdrm, +) + openclose = executable( 'tegra-openclose', files('openclose.c'),
@@ -35,3 +45,12 @@ openclose = executable( link_with : [libdrm, libdrm_tegra], install : with_install_tests, ) + +gr2d_fill = executable( + 'tegra-gr2d-fill', + files('gr2d-fill.c'), + include_directories : [inc_root, inc_drm, inc_tegra], + c_args : libdrm_c_args, + link_with : [libdrm, libdrm_tegra, libdrm_test, libdrm_test_tegra], + install : with_install_tests, +)
Signature · 1 line
2.35.1
PATCH v2 16/25 tests: tegra: Add syncpt-wait test
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
This is a very simple sanity test to check whether or not a syncpt can be incremented by a host1x client. This uses gr2d on Tegra20 through Tegra114 and VIC on Tegra124 and later.
--- tests/tegra/meson.build | 9 +++ tests/tegra/syncpt-wait.c | 151 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 160 insertions(+) create mode 100644 tests/tegra/syncpt-wait.c
tests/tegra/meson.build +9 -0
@@ -54,3 +54,12 @@ gr2d_fill = executable( link_with : [libdrm, libdrm_tegra, libdrm_test, libdrm_test_tegra], install : with_install_tests, ) + +syncpt_wait = executable( + 'tegra-syncpt-wait', + files('syncpt-wait.c'), + include_directories : [inc_root, inc_drm, inc_tegra], + c_args : libdrm_c_args, + link_with : [libdrm, libdrm_tegra, libdrm_test, libdrm_test_tegra], + install : with_install_tests, +)
tests/tegra/syncpt-wait.c new file +151 -0
151 lines not on this page · raw message
Signature · 1 line
2.35.1
PATCH v2 17/25 tests: tegra: Add syncpoint timeout test
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
This test can be used to purposefully trigger a job timeout.
--- tests/tegra/meson.build | 9 ++ tests/tegra/syncpt-timeout.c | 163 +++++++++++++++++++++++++++++++++++ 2 files changed, 172 insertions(+) create mode 100644 tests/tegra/syncpt-timeout.c
tests/tegra/meson.build +9 -0
@@ -63,3 +63,12 @@ syncpt_wait = executable( link_with : [libdrm, libdrm_tegra, libdrm_test, libdrm_test_tegra], install : with_install_tests, ) + +syncpt_timeout = executable( + 'tegra-syncpt-timeout', + files('syncpt-timeout.c'), + include_directories : [inc_root, inc_drm, inc_tegra], + c_args : libdrm_c_args, + link_with : [libdrm, libdrm_tegra, libdrm_test, libdrm_test_tegra], + install : with_install_tests, +)
tests/tegra/syncpt-timeout.c new file +163 -0
163 lines not on this page · raw message
Signature · 1 line
2.35.1
PATCH v2 18/25 tests: tegra: Add VIC support
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
Implement a small abstraction interface to allow different versions of VIC to be used transparently. An implementation will be chosen based on the VIC version number reported by the DRM_TEGRA_IOCTL_OPEN_CHANNEL IOCTL.
--- tests/tegra/host1x.h | 34 ++++++++ tests/tegra/meson.build | 2 + tests/tegra/vic.c | 159 +++++++++++++++++++++++++++++++++++ tests/tegra/vic.h | 181 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 376 insertions(+) create mode 100644 tests/tegra/host1x.h create mode 100644 tests/tegra/vic.c create mode 100644 tests/tegra/vic.h
tests/tegra/host1x.h new file +34 -0
@@ -0,0 +1,34 @@ +/* +* Copyright © 2018 NVIDIA Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef HOST1X_H +#define HOST1X_H + +#define HOST1X_OPCODE_SETCL (offset, classid, mask) \ + ((0x0 << 28) | (((offset) & 0xfff) << 16) | (((classid) & 0x3ff) << 6) | ((mask) & 0x3f)) + +#define HOST1X_OPCODE_INCR (offset, count) \ + ((0x1 << 28) | (((offset) & 0xfff) << 16) | ((count) & 0xffff)) + +#define HOST1X_CLASS_VIC 0x5d + +#endif
tests/tegra/meson.build +2 -0
@@ -32,6 +32,8 @@ libdrm_test_tegra = static_library( [files( 'drm-test-tegra.c', 'drm-test-tegra.h', + 'vic.c', + 'vic.h', ), config_file ], include_directories : [inc_root, inc_drm, inc_tegra], link_with : libdrm,
tests/tegra/vic.c new file +159 -0
159 lines not on this page · raw message
tests/tegra/vic.h new file +181 -0
181 lines not on this page · raw message
Signature · 1 line
2.35.1
PATCH v2 19/25 tests: tegra: Add VIC 3.0 support
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
The Video Image Composer (VIC) 3.0 can be found on NVIDIA Tegra124 SoCs.
--- tegra/private.h | 6 + tests/tegra/meson.build | 2 + tests/tegra/vic.c | 8 +- tests/tegra/vic30.c | 458 ++++++++++++++++++++++++++++++++++++++++ tests/tegra/vic30.h | 439 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 911 insertions(+), 2 deletions(-) create mode 100644 tests/tegra/vic30.c create mode 100644 tests/tegra/vic30.h
tegra/private.h +6 -0
@@ -26,6 +26,7 @@#define __DRM_TEGRA_PRIVATE_H__ 1#include <stdbool.h> +#include <stddef.h> #include <stdint.h> #include <libdrm_macros.h>
@@ -34,6 +35,11 @@#include "tegra_drm.h" #include "tegra.h" +#define container_of (ptr, type, member) ({ \ + const __typeof__(((type *)0)->member) *__mptr = (ptr); \ + (type *)((char *)__mptr - offsetof(type, member)); \ + }) +enum host1x_class {HOST1X_CLASS_HOST1X =0x01 ,HOST1X_CLASS_GR2D =0x51 ,
tests/tegra/meson.build +2 -0
@@ -34,6 +34,8 @@ libdrm_test_tegra = static_library( 'drm-test-tegra.h', 'vic.c', 'vic.h', + 'vic30.c', + 'vic30.h', ), config_file ], include_directories : [inc_root, inc_drm, inc_tegra], link_with : libdrm,
tests/tegra/vic.c +6 -2
@@ -130,6 +130,10 @@ void vic_image_dump(struct vic_image *image, FILE *fp)drm_tegra_bo_unmap (image->bo); } +/* from vic30.c */ +int vic30_new (struct drm_tegra *drm,struct drm_tegra_channel *channel, +struct vic **vicp); +int vic_new (struct drm_tegra *drm,struct drm_tegra_channel *channel,struct vic **vicp) {
@@ -138,8 +142,8 @@ int vic_new(struct drm_tegra *drm, struct drm_tegra_channel *channel, version =drm_tegra_channel_get_version (channel);switch (version) { -default : -break ; +case 0x40 : +return vic30_new (drm, channel, vicp); }return -ENOTSUP ;
tests/tegra/vic30.c new file +458 -0
458 lines not on this page · raw message
tests/tegra/vic30.h new file +439 -0
439 lines not on this page · raw message
Signature · 1 line
2.35.1
PATCH v2 20/25 tests: tegra: Add VIC 4.0 support
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
The Video Image Composer (VIC) 4.0 can be found on NVIDIA Tegra210 SoCs. It uses a different class (B0B6) that is slightly incompatible with the class found on earlier generations.
--- tests/tegra/meson.build | 2 + tests/tegra/vic.c | 7 + tests/tegra/vic40.c | 370 ++++++++++++++++++++++++++++++++++++++++ tests/tegra/vic40.h | 285 +++++++++++++++++++++++++++++++ 4 files changed, 664 insertions(+) create mode 100644 tests/tegra/vic40.c create mode 100644 tests/tegra/vic40.h
tests/tegra/meson.build +2 -0
@@ -36,6 +36,8 @@ libdrm_test_tegra = static_library( 'vic.h', 'vic30.c', 'vic30.h', + 'vic40.c', + 'vic40.h', ), config_file ], include_directories : [inc_root, inc_drm, inc_tegra], link_with : libdrm,
tests/tegra/vic.c +7 -0
@@ -134,6 +134,10 @@ void vic_image_dump(struct vic_image *image, FILE *fp)int vic30_new (struct drm_tegra *drm,struct drm_tegra_channel *channel,struct vic **vicp); +/* from vic40.c */ +int vic40_new (struct drm_tegra *drm,struct drm_tegra_channel *channel, +struct vic **vicp); +int vic_new (struct drm_tegra *drm,struct drm_tegra_channel *channel,struct vic **vicp) {
@@ -144,6 +148,9 @@ int vic_new(struct drm_tegra *drm, struct drm_tegra_channel *channel,switch (version) {case 0x40 :return vic30_new (drm, channel, vicp); + +case 0x21 : +return vic40_new (drm, channel, vicp); }return -ENOTSUP ;
tests/tegra/vic40.c new file +370 -0
370 lines not on this page · raw message
tests/tegra/vic40.h new file +285 -0
285 lines not on this page · raw message
Signature · 1 line
2.35.1
Re: [PATCH libdrm v2 20/25] tests: tegra: Add VIC 4.0 support
Quoted 98 lines · Thierry Reding
From: Thierry Reding <[email protected]>
The Video Image Composer (VIC) 4.0 can be found on NVIDIA Tegra210 SoCs. It uses a different class (B0B6) that is slightly incompatible with the class found on earlier generations.
Signed-off-by Thierry Reding <[email protected]>--- tests/tegra/meson.build | 2 + tests/tegra/vic.c | 7 + tests/tegra/vic40.c | 370 ++++++++++++++++++++++++++++++++++++++++ tests/tegra/vic40.h | 285 +++++++++++++++++++++++++++++++ 4 files changed, 664 insertions(+)create mode 100644
tests/tegra/vic40.c
create mode 100644tests/tegra/vic40.htests/tegra/meson.build +2
-0@@ -36,6 +36,8 @@ libdrm_test_tegra = static_library( 'vic.h', 'vic30.c', 'vic30.h', + 'vic40.c', + 'vic40.h', ), config_file ], include_directories : [inc_root, inc_drm, inc_tegra], link_with : libdrm,tests/tegra/vic.c +7
-0@@ -134,6 +134,10 @@ void vic_image_dump(struct vic_image *image, FILE *fp)int vic30_new (struct drm_tegra *drm,struct drm_tegra_channel *channel,struct vic **vicp); +/* from vic40.c */ +int vic40_new (struct drm_tegra *drm,struct drm_tegra_channel *channel, +struct vic **vicp); +int vic_new (struct drm_tegra *drm,struct drm_tegra_channel *channel,struct vic **vicp) {@@ -144,6 +148,9 @@ int vic_new(struct drm_tegra *drm, struct drm_tegra_channel *channel,switch (version) {case 0x40 :return vic30_new (drm, channel, vicp); + +case 0x21 : +return vic40_new (drm, channel, vicp); }return -ENOTSUP ;tests/tegra/vic40.c new file +38
-0@@ -0,0 +1,370 @@ +/* +* Copyright © 2018 NVIDIA Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <errno.h> +#include <string.h> + +#include "private.h" +#include "tegra.h" +#include "vic.h" +#include "vic40.h" + +struct vic40 { +struct vic base; + +struct { +struct drm_tegra_mapping *map; +struct drm_tegra_bo *bo; + } config; +
tests/tegra/vic40.c line 48
Quoted 10 lines
tests/tegra/vic40.c new file +10
-0+struct { +struct drm_tegra_mapping *map; +struct drm_tegra_bo *bo; + } filter; + +struct { +struct drm_tegra_mapping *map; +struct drm_tegra_bo *bo; + } hist; +};
Histogram buffer not necessary at least on VIC4.0 and later. (Same applies to VIC4.1 and VIC4.2 patches).
Also not sure if it's worth duplicating all this for the very minor differences between VIC4.0/4.1/4.2?
Quoted 613 lines
tests/tegra/vic40.c new file +322
-0+ +static int vic40_fill (struct vic *v,struct vic_image *output, +unsigned int left,unsigned int top, +unsigned int right,unsigned int bottom, +unsigned int alpha,unsigned int red, +unsigned int green,unsigned int blue) +{ + struct vic40 *vic = container_of(v, struct vic40, base); +ConfigStruct *c; +int err; + + err =drm_tegra_bo_map (vic->config.bo, (void **)&c); +if (err <0 ) { +fprintf (stderr,"failed to map configuration structure: %s\n" , +strerror (-err)); +return err; + } + +memset (c,0 ,sizeof (*c)); + + c->outputConfig.TargetRectTop = top; + c->outputConfig.TargetRectLeft = left; + c->outputConfig.TargetRectRight = right; + c->outputConfig.TargetRectBottom = bottom; + c->outputConfig.BackgroundAlpha = alpha; + c->outputConfig.BackgroundR = red; + c->outputConfig.BackgroundG = green; + c->outputConfig.BackgroundB = blue; + + c->outputSurfaceConfig.OutPixelFormat = output->format; + c->outputSurfaceConfig.OutBlkKind = output->kind; + c->outputSurfaceConfig.OutBlkHeight =0 ; + c->outputSurfaceConfig.OutSurfaceWidth = output->width -1 ; + c->outputSurfaceConfig.OutSurfaceHeight = output->height -1 ; + c->outputSurfaceConfig.OutLumaWidth = output->stride -1 ; + c->outputSurfaceConfig.OutLumaHeight = output->height -1 ; + c->outputSurfaceConfig.OutChromaWidth =16383 ; + c->outputSurfaceConfig.OutChromaHeight =16383 ; + +drm_tegra_bo_unmap (vic->config.bo); + +return 0 ; +} + +static int vic40_blit (struct vic *v,struct vic_image *output, +struct vic_image *input) +{ + struct vic40 *vic = container_of(v, struct vic40, base); +SlotSurfaceConfig *surface; +SlotConfig *slot; +ConfigStruct *c; +int err; + + err =drm_tegra_bo_map (vic->config.bo, (void **)&c); +if (err <0 ) { +fprintf (stderr,"failed to map configuration structure: %s\n" , +strerror (-err)); +return err; + } + +memset (c,0 ,sizeof (*c)); + + c->outputConfig.TargetRectTop =0 ; + c->outputConfig.TargetRectLeft =0 ; + c->outputConfig.TargetRectRight = output->width -1 ; + c->outputConfig.TargetRectBottom = output->height -1 ; + c->outputConfig.BackgroundAlpha =1023 ; + c->outputConfig.BackgroundR =1023 ; + c->outputConfig.BackgroundG =1023 ; + c->outputConfig.BackgroundB =1023 ; + + c->outputSurfaceConfig.OutPixelFormat = output->format; + c->outputSurfaceConfig.OutBlkKind = output->kind; + c->outputSurfaceConfig.OutBlkHeight =0 ; + c->outputSurfaceConfig.OutSurfaceWidth = output->width -1 ; + c->outputSurfaceConfig.OutSurfaceHeight = output->height -1 ; + c->outputSurfaceConfig.OutLumaWidth = output->stride -1 ; + c->outputSurfaceConfig.OutLumaHeight = output->height -1 ; + c->outputSurfaceConfig.OutChromaWidth =16383 ; + c->outputSurfaceConfig.OutChromaHeight =16383 ; + + slot = &c->slotStruct[0 ].slotConfig; + slot->SlotEnable =1 ; + slot->CurrentFieldEnable =1 ; + slot->PlanarAlpha =1023 ; + slot->ConstantAlpha =1 ; + slot->SourceRectLeft =0 <<16 ; + slot->SourceRectRight = (input->width -1 ) <<16 ; + slot->SourceRectTop =0 <<16 ; + slot->SourceRectBottom = (input->height -1 ) <<16 ; + slot->DestRectLeft =0 ; + slot->DestRectRight = output->width -1 ; + slot->DestRectTop =0 ; + slot->DestRectBottom = output->height -1 ; + slot->SoftClampHigh =1023 ; + + surface = &c->slotStruct[0 ].slotSurfaceConfig; + surface->SlotPixelFormat = input->format; + surface->SlotBlkKind = input->kind; + surface->SlotBlkHeight =0 ;/* XXX */ + surface->SlotCacheWidth = VIC_CACHE_WIDTH_64Bx4;/* XXX */ + surface->SlotSurfaceWidth = input->width -1 ; + surface->SlotSurfaceHeight = input->height -1 ; + surface->SlotLumaWidth = input->stride -1 ; + surface->SlotLumaHeight = input->height -1 ; + surface->SlotChromaWidth =16383 ; + surface->SlotChromaHeight =16383 ; + +drm_tegra_bo_unmap (vic->config.bo); + +return 0 ; +} + +static int vic40_flip (struct vic *v,struct vic_image *output, +struct vic_image *input) +{ + struct vic40 *vic = container_of(v, struct vic40, base); +SlotSurfaceConfig *surface; +SlotConfig *slot; +ConfigStruct *c; +int err; + + err =drm_tegra_bo_map (vic->config.bo, (void **)&c); +if (err <0 ) { +fprintf (stderr,"failed to map configuration structure: %s\n" , +strerror (-err)); +return err; + } + +memset (c,0 ,sizeof (*c)); + + c->outputConfig.TargetRectTop =0 ; + c->outputConfig.TargetRectLeft =0 ; + c->outputConfig.TargetRectRight = output->width -1 ; + c->outputConfig.TargetRectBottom = output->height -1 ; + c->outputConfig.BackgroundAlpha =1023 ; + c->outputConfig.BackgroundR =1023 ; + c->outputConfig.BackgroundG =1023 ; + c->outputConfig.BackgroundB =1023 ; + c->outputConfig.OutputFlipY =1 ; + + c->outputSurfaceConfig.OutPixelFormat = output->format; + c->outputSurfaceConfig.OutBlkKind = output->kind; + c->outputSurfaceConfig.OutBlkHeight =0 ; + c->outputSurfaceConfig.OutSurfaceWidth = output->width -1 ; + c->outputSurfaceConfig.OutSurfaceHeight = output->height -1 ; + c->outputSurfaceConfig.OutLumaWidth = output->stride -1 ; + c->outputSurfaceConfig.OutLumaHeight = output->height -1 ; + c->outputSurfaceConfig.OutChromaWidth =16383 ; + c->outputSurfaceConfig.OutChromaHeight =16383 ; + + slot = &c->slotStruct[0 ].slotConfig; + slot->SlotEnable =1 ; + slot->CurrentFieldEnable =1 ; + slot->PlanarAlpha =1023 ; + slot->ConstantAlpha =1 ; + slot->SourceRectLeft =0 <<16 ; + slot->SourceRectRight = (input->width -1 ) <<16 ; + slot->SourceRectTop =0 <<16 ; + slot->SourceRectBottom = (input->height -1 ) <<16 ; + slot->DestRectLeft =0 ; + slot->DestRectRight = output->width -1 ; + slot->DestRectTop =0 ; + slot->DestRectBottom = output->height -1 ; + slot->SoftClampHigh =1023 ; + + surface = &c->slotStruct[0 ].slotSurfaceConfig; + surface->SlotPixelFormat = input->format; + surface->SlotBlkKind = input->kind; + surface->SlotBlkHeight =0 ;/* XXX */ + surface->SlotCacheWidth = VIC_CACHE_WIDTH_64Bx4;/* XXX */ + surface->SlotSurfaceWidth = input->width -1 ; + surface->SlotSurfaceHeight = input->height -1 ; + surface->SlotLumaWidth = input->stride -1 ; + surface->SlotLumaHeight = input->height -1 ; + surface->SlotChromaWidth =16383 ; + surface->SlotChromaHeight =16383 ; + +drm_tegra_bo_unmap (vic->config.bo); + +return 0 ; +} + +static int vic40_execute (struct vic *v,struct drm_tegra_pushbuf *pushbuf, +uint32_t **ptrp,struct vic_image *output, +struct vic_image **inputs,unsigned int num_inputs) +{ + struct vic40 *vic = container_of(v, struct vic40, base); +unsigned int i; + +if (num_inputs >1 ) +return -EINVAL ; + +VIC_PUSH_METHOD (pushbuf, ptrp,NVB0B6_VIDEO_COMPOSITOR_SET_APPLICATION_ID ,1 ); +VIC_PUSH_METHOD (pushbuf, ptrp,NVB0B6_VIDEO_COMPOSITOR_SET_CONTROL_PARAMS , (sizeof (ConfigStruct) /16 ) <<16 ); +VIC_PUSH_BUFFER (pushbuf, ptrp,NVB0B6_VIDEO_COMPOSITOR_SET_CONFIG_STRUCT_OFFSET , vic->config.map,0 ,0 ); +VIC_PUSH_BUFFER (pushbuf, ptrp,NVB0B6_VIDEO_COMPOSITOR_SET_OUTPUT_SURFACE_LUMA_OFFSET , output->map,0 ,0 ); + +for (i =0 ; i < num_inputs; i++) +VIC_PUSH_BUFFER (pushbuf, ptrp,NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE0_SLOT0_LUMA_OFFSET , inputs[i]->map,0 ,0 ); + +VIC_PUSH_METHOD (pushbuf, ptrp,NVB0B6_VIDEO_COMPOSITOR_EXECUTE ,1 <<8 ); + +return 0 ; +} + +static void vic40_free (struct vic *v) +{ + struct vic40 *vic = container_of(v, struct vic40, base); + +drm_tegra_channel_unmap (vic->hist.map); +drm_tegra_bo_unref (vic->hist.bo); + +drm_tegra_channel_unmap (vic->filter.map); +drm_tegra_bo_unref (vic->filter.bo); + +drm_tegra_channel_unmap (vic->config.map); +drm_tegra_bo_unref (vic->config.bo); + +drm_tegra_syncpoint_free (v->syncpt); + +free (vic); +} + +static const struct vic_ops vic40_ops = { + .fill = vic40_fill, + .blit = vic40_blit, + .flip = vic40_flip, + .execute = vic40_execute, + .free = vic40_free, +}; + +int vic40_new (struct drm_tegra *drm,struct drm_tegra_channel *channel, +struct vic **vicp) +{ +struct vic40 *vic; +void *ptr; +int err; + + vic =calloc (1 ,sizeof (*vic)); +if (!vic) +return -ENOMEM ; + + vic->base.drm = drm; + vic->base.channel = channel; + vic->base.ops = &vic40_ops; + vic->base.version =0x21 ; + + err =drm_tegra_syncpoint_new (drm, &vic->base.syncpt); +if (err <0 ) { +fprintf (stderr,"failed to allocate syncpoint: %s\n" ,strerror (-err)); +return err; + } + + err =drm_tegra_bo_new (drm,0 ,16384 , &vic->config.bo); +if (err <0 ) { +fprintf (stderr,"failed to allocate configuration structurer: %s\n" , +strerror (-err)); +return err; + } + + err =drm_tegra_channel_map (channel, vic->config.bo,DRM_TEGRA_CHANNEL_MAP_READ , + &vic->config.map); +if (err <0 ) { +fprintf (stderr,"failed to map configuration structure: %s\n" , +strerror (-err)); +return err; + } + + err =drm_tegra_bo_new (drm,0 ,16384 , &vic->filter.bo); +if (err <0 ) { +fprintf (stderr,"failed to allocate filter buffer: %s\n" , +strerror (-err)); +return err; + } + + err =drm_tegra_bo_map (vic->filter.bo, &ptr); +if (err <0 ) { +fprintf (stderr,"failed to map filter buffer: %s\n" ,strerror (-err)); +return err; + } + +memset (ptr,0 ,16384 ); +drm_tegra_bo_unmap (vic->filter.bo); + + err =drm_tegra_channel_map (channel, vic->filter.bo,DRM_TEGRA_CHANNEL_MAP_READ , + &vic->filter.map); +if (err <0 ) { +fprintf (stderr,"failed to map filter buffer: %s\n" , +strerror (-err)); +return err; + } + + err =drm_tegra_bo_new (drm,0 ,4096 , &vic->hist.bo); +if (err <0 ) { +fprintf (stderr,"failed to allocate history buffer: %s\n" , +strerror (-err)); +return err; + } + + err =drm_tegra_bo_map (vic->hist.bo, &ptr); +if (err <0 ) { +fprintf (stderr,"failed to map history buffer: %s\n" ,strerror (-err)); +return err; + } + +memset (ptr,0 ,4096 ); +drm_tegra_bo_unmap (vic->hist.bo); + + err =drm_tegra_channel_map (channel, vic->hist.bo,DRM_TEGRA_CHANNEL_MAP_READ_WRITE , + &vic->hist.map); +if (err <0 ) { +fprintf (stderr,"failed to map histogram buffer: %s\n" , +strerror (-err)); +return err; + } + +if (vicp) + *vicp = &vic->base; + +return 0 ; +}tests/tegra/vic40.h new file +285
-0@@ -0,0 +1,285 @@ +/* +* Copyright © 2016-2018 NVIDIA Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef VIC40_H +#define VIC40_H + +#include <stdint.h> + +#define NVB0B6_VIDEO_COMPOSITOR_SET_APPLICATION_ID 0x00000200 +#define NVB0B6_VIDEO_COMPOSITOR_EXECUTE 0x00000300 +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE0_SLOT0_LUMA_OFFSET 0x00000400 +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE0_SLOT0_CHROMA_U_OFFSET 0x00000404 +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE0_SLOT0_CHROMA_V_OFFSET 0x00000408 +#define NVB0B6_VIDEO_COMPOSITOR_SET_CONTROL_PARAMS 0x00000704 +#define NVB0B6_VIDEO_COMPOSITOR_SET_CONFIG_STRUCT_OFFSET 0x00000708 +#define NVB0B6_VIDEO_COMPOSITOR_SET_HIST_OFFSET 0x00000714 +#define NVB0B6_VIDEO_COMPOSITOR_SET_OUTPUT_SURFACE_LUMA_OFFSET 0x00000720 + +typedef struct { +uint64_t SlotEnable :1 ;/* 0 */ +uint64_t DeNoise :1 ;/* 1 */ +uint64_t AdvancedDenoise :1 ;/* 2 */ +uint64_t CadenceDetect :1 ;/* 3 */ +uint64_t MotionMap :1 ;/* 4 */ +uint64_t MMapCombine :1 ;/* 5 */ +uint64_t IsEven :1 ;/* 6 */ +uint64_t ChromaEven :1 ;/* 7 */ +uint64_t CurrentFieldEnable :1 ;/* 8 */ +uint64_t PrevFieldEnable :1 ;/* 9 */ +uint64_t NextFieldEnable :1 ;/* 10 */ +uint64_t NextNrFieldEnable :1 ;/* 11 */ +uint64_t CurMotionFieldEnable :1 ;/* 12 */ +uint64_t PrevMotionFieldEnable :1 ;/* 13 */ +uint64_t PpMotionFieldEnable :1 ;/* 14 */ +uint64_t CombMotionFieldEnable :1 ;/* 15 */ +uint64_t FrameFormat :4 ;/* 19..16 */ +uint64_t FilterLengthY :2 ;/* 21..20 */ +uint64_t FilterLengthX :2 ;/* 23..22 */ +uint64_t Panoramic :12 ;/* 35..24 */ +uint64_t reserved1 :22 ;/* 57..36 */ +uint64_t DetailFltClamp :6 ;/* 63..58 */ +uint64_t FilterNoise :10 ;/* 73..64 */ +uint64_t FilterDetail :10 ;/* 83..74 */ +uint64_t ChromaNoise :10 ;/* 93..84 */ +uint64_t ChromaDetail :10 ;/* 103..94 */ +uint64_t DeinterlaceMode :4 ;/* 107..104 */ +uint64_t MotionAccumWeight :3 ;/* 110..108 */ +uint64_t NoiseIir :11 ;/* 121..111 */ +uint64_t LightLevel :4 ;/* 125..122 */ +uint64_t reserved4 :2 ;/* 127..126 */ +/* 128 */ +uint64_t SoftClampLow :10 ;/* 9..0 */ +uint64_t SoftClampHigh :10 ;/* 19..10 */ +uint64_t reserved5 :3 ;/* 22..20 */ +uint64_t reserved6 :9 ;/* 31..23 */ +uint64_t PlanarAlpha :10 ;/* 41..32 */ +uint64_t ConstantAlpha :1 ;/* 42 */ +uint64_t StereoInterleave :3 ;/* 45..43 */ +uint64_t ClipEnabled :1 ;/* 46 */ +uint64_t ClearRectMask :8 ;/* 54..47 */ +uint64_t DegammaMode :2 ;/* 56..55 */ +uint64_t reserved7 :1 ;/* 57 */ +uint64_t DecompressEnable :1 ;/* 58 */ +uint64_t reserved9 :5 ;/* 63..59 */ +uint64_t DecompressCtbCount :8 ;/* 71..64 */ +uint64_t DecompressZbcColor :32 ;/* 103..72 */ +uint64_t reserved12 :24 ;/* 127..104 */ +/* 256 */ +uint64_t SourceRectLeft :30 ;/* 29..0 */ +uint64_t reserved14 :2 ;/* 31..30 */ +uint64_t SourceRectRight :30 ;/* 61..32 */ +uint64_t reserved15 :2 ;/* 63..62 */ +uint64_t SourceRectTop :30 ;/* 93..64 */ +uint64_t reserved16 :2 ;/* 95..94 */ +uint64_t SourceRectBottom :30 ;/* 125..96 */ +uint64_t reserved17 :2 ;/* 127..126 */ +/* 384 */ +uint64_t DestRectLeft :14 ;/* 13..0 */ +uint64_t reserved18 :2 ;/* 15..14 */ +uint64_t DestRectRight :14 ;/* 29..16 */ +uint64_t reserved19 :2 ;/* 31..30 */ +uint64_t DestRectTop :14 ;/* 45..32 */ +uint64_t reserved20 :2 ;/* 47..46 */ +uint64_t DestRectBottom :14 ;/* 61..48 */ +uint64_t reserved21 :2 ;/* 63..62 */ +uint64_t reserved22 :32 ;/* 95..64 */ +uint64_t reserved23 :32 ;/* 127..96 */ +}SlotConfig ; + +typedef struct { +uint64_t SlotPixelFormat :7 ;/* 6..0 */ +uint64_t SlotChromaLocHoriz :2 ;/* 8..7 */ +uint64_t SlotChromaLocVert :2 ;/* 10..9 */ +uint64_t SlotBlkKind :4 ;/* 14..11 */ +uint64_t SlotBlkHeight :4 ;/* 18..15 */ +uint64_t SlotCacheWidth :3 ;/* 21..19 */ +uint64_t reserved0 :10 ;/* 31..22 */ +uint64_t SlotSurfaceWidth :14 ;/* 45..32 */ +uint64_t SlotSurfaceHeight :14 ;/* 59..46 */ +uint64_t reserved1 :4 ;/* 63..60 */ +uint64_t SlotLumaWidth :14 ;/* 77..64 */ +uint64_t SlotLumaHeight :14 ;/* 91..78 */ +uint64_t reserved2 :4 ;/* 95..92 */ +uint64_t SlotChromaWidth :14 ;/* 109..96 */ +uint64_t SlotChromaHeight :14 ;/* 123..110 */ +uint64_t reserved3 :4 ;/* 127..124 */ +}SlotSurfaceConfig ; + +typedef struct { +uint64_t luma_coeff0 :20 ;/* 19..0 */ +uint64_t luma_coeff1 :20 ;/* 39..20 */ +uint64_t luma_coeff2 :20 ;/* 59..40 */ +uint64_t luma_r_shift :4 ;/* 63..60 */ +uint64_t luma_coeff3 :20 ;/* 83..64 */ +uint64_t LumaKeyLower :10 ;/* 93..84 */ +uint64_t LumaKeyUpper :10 ;/* 103..94 */ +uint64_t LumaKeyEnabled :1 ;/* 104 */ +uint64_t reserved0 :2 ;/* 106..105 */ +uint64_t reserved1 :21 ;/* 127..107 */ +}LumaKeyStruct ; + +typedef struct { +uint64_t matrix_coeff00 :20 ;/* 19..0 */ +uint64_t matrix_coeff10 :20 ;/* 39..20 */ +uint64_t matrix_coeff20 :20 ;/* 59..40 */ +uint64_t matrix_r_shift :4 ;/* 63..60 */ +uint64_t matrix_coeff01 :20 ;/* 83..64 */ +uint64_t matrix_coeff11 :20 ;/* 103..84 */ +uint64_t matrix_coeff21 :20 ;/* 123..104 */ +uint64_t reserved0 :3 ;/* 126..124 */ +uint64_t matrix_enable :1 ;/* 127 */ +/* 128 */ +uint64_t matrix_coeff02 :20 ;/* 19..0 */ +uint64_t matrix_coeff12 :20 ;/* 39..20 */ +uint64_t matrix_coeff22 :20 ;/* 59..40 */ +uint64_t reserved1 :4 ;/* 63..60 */ +uint64_t matrix_coeff03 :20 ;/* 83..64 */ +uint64_t matrix_coeff13 :20 ;/* 103..84 */ +uint64_t matrix_coeff23 :20 ;/* 123..104 */ +uint64_t reserved2 :4 ;/* 127..124 */ +}MatrixStruct ; + +typedef struct { +uint64_t ClearRect0Left :14 ;/* 13..0 */ +uint64_t reserved0 :2 ;/* 15..14 */ +uint64_t ClearRect0Right :14 ;/* 29..16 */ +uint64_t reserved1 :2 ;/* 31..30 */ +uint64_t ClearRect0Top :14 ;/* 45..32 */ +uint64_t reserved2 :2 ;/* 47..46 */ +uint64_t ClearRect0Bottom :14 ;/* 61..48 */ +uint64_t reserved3 :2 ;/* 63..62 */ +uint64_t ClearRect1Left :14 ;/* 77..64 */ +uint64_t reserved4 :2 ;/* 79..78 */ +uint64_t ClearRect1Right :14 ;/* 93..80 */ +uint64_t reserved5 :2 ;/* 95..94 */ +uint64_t ClearRect1Top :14 ;/* 109..96 */ +uint64_t reserved6 :2 ;/* 111..110 */ +uint64_t ClearRect1Bottom :14 ;/* 125..112 */ +uint64_t reserved7 :2 ;/* 127..126 */ +}ClearRectStruct ; + +typedef struct { +uint64_t AlphaK1 :10 ;/* 9..0 */ +uint64_t reserved0 :6 ;/* 15..10 */ +uint64_t AlphaK2 :10 ;/* 25..16 */ +uint64_t reserved1 :6 ;/* 31..26 */ +uint64_t SrcFactCMatchSelect :3 ;/* 34..32 */ +uint64_t reserved2 :1 ;/* 35 */ +uint64_t DstFactCMatchSelect :3 ;/* 38..36 */ +uint64_t reserved3 :1 ;/* 39 */ +uint64_t SrcFactAMatchSelect :3 ;/* 42..40 */ +uint64_t reserved4 :1 ;/* 43 */ +uint64_t DstFactAMatchSelect :3 ;/* 46..44 */ +uint64_t reserved5 :1 ;/* 47 */ +uint64_t reserved6 :4 ;/* 51..48 */ +uint64_t reserved7 :4 ;/* 55..52 */ +uint64_t reserved8 :4 ;/* 59..56 */ +uint64_t reserved9 :4 ;/* 63..60 */ +uint64_t reserved10 :2 ;/* 65..64 */ +uint64_t OverrideR :10 ;/* 75..66 */ +uint64_t OverrideG :10 ;/* 85..76 */ +uint64_t OverrideB :10 ;/* 95..86 */ +uint64_t OverrideA :10 ;/* 105..96 */ +uint64_t reserved11 :2 ;/* 107..106 */ +uint64_t UseOverrideR :1 ;/* 108 */ +uint64_t UseOverrideG :1 ;/* 109 */ +uint64_t UseOverrideB :1 ;/* 110 */ +uint64_t UseOverrideA :1 ;/* 111 */ +uint64_t MaskR :1 ;/* 112 */ +uint64_t MaskG :1 ;/* 113 */ +uint64_t MaskB :1 ;/* 114 */ +uint64_t MaskA :1 ;/* 115 */ +uint64_t reserved12 :12 ;/* 127..116 */ +}BlendingSlotStruct ; + +typedef struct { +uint64_t AlphaFillMode :3 ;/* 2..0 */ +uint64_t AlphaFillSlot :3 ;/* 5..3 */ +uint64_t BackgroundAlpha :10 ;/* 15..6 */ +uint64_t BackgroundR :10 ;/* 25..16 */ +uint64_t BackgroundG :10 ;/* 35..26 */ +uint64_t BackgroundB :10 ;/* 45..36 */ +uint64_t RegammaMode :2 ;/* 47..46 */ +uint64_t OutputFlipX :1 ;/* 48 */ +uint64_t OutputFlipY :1 ;/* 49 */ +uint64_t OutputTranspose :1 ;/* 50 */ +uint64_t reserved1 :1 ;/* 51 */ +uint64_t reserved2 :12 ;/* 63..52 */ +uint64_t TargetRectLeft :14 ;/* 77..64 */ +uint64_t reserved3 :2 ;/* 79..78 */ +uint64_t TargetRectRight :14 ;/* 93..80 */ +uint64_t reserved4 :2 ;/* 95..94 */ +uint64_t TargetRectTop :14 ;/* 109..96 */ +uint64_t reserved5 :2 ;/* 111..110 */ +uint64_t TargetRectBottom :14 ;/* 125..112 */ +uint64_t reserved6 :2 ;/* 127..126 */ +}OutputConfig ; + +typedef struct { +uint64_t OutPixelFormat :7 ;/* 6..0 */ +uint64_t OutChromaLocHoriz :2 ;/* 8..7 */ +uint64_t OutChromaLocVert :2 ;/* 10..9 */ +uint64_t OutBlkKind :4 ;/* 14..11 */ +uint64_t OutBlkHeight :4 ;/* 18..15 */ +uint64_t reserved0 :3 ;/* 21..19 */ +uint64_t reserved1 :10 ;/* 31..22 */ +uint64_t OutSurfaceWidth :14 ;/* 45..32 */ +uint64_t OutSurfaceHeight :14 ;/* 59..46 */ +uint64_t reserved2 :4 ;/* 63..60 */ +uint64_t OutLumaWidth :14 ;/* 77..64 */ +uint64_t OutLumaHeight :14 ;/* 91..78 */ +uint64_t reserved3 :4 ;/* 95..92 */ +uint64_t OutChromaWidth :14 ;/* 109..96 */ +uint64_t OutChromaHeight :14 ;/* 123..110 */ +uint64_t reserved4 :4 ;/* 127..124 */ +}OutputSurfaceConfig ; + +typedef struct { +uint64_t DownsampleHoriz :11 ;/* 10..0 */ +uint64_t reserved0 :5 ;/* 15..11 */ +uint64_t DownsampleVert :11 ;/* 26..16 */ +uint64_t reserved1 :5 ;/* 31..27 */ +uint64_t reserved2 :32 ;/* 63..32 */ +uint64_t reserved3 :32 ;/* 95..64 */ +uint64_t reserved4 :32 ;/* 127..96 */ +}PipeConfig ; + +typedef struct { +SlotConfig slotConfig; +SlotSurfaceConfig slotSurfaceConfig; +LumaKeyStruct lumaKeyStruct; +MatrixStruct colorMatrixStruct; +MatrixStruct gamutMatrixStruct; +BlendingSlotStruct blendingSlotStruct; +}SlotStruct ; + +typedef struct { +PipeConfig pipeConfig; +OutputConfig outputConfig; +OutputSurfaceConfig outputSurfaceConfig; +MatrixStruct outColorMatrixStruct; +ClearRectStruct clearRectStruct[4 ]; +SlotStruct slotStruct[8 ]; +}ConfigStruct ; + +#endif
Re: [PATCH libdrm v2 20/25] tests: tegra: Add VIC 4.0 support
Quoted 102 lines · Mikko Perttunen
Quoted 101 lines · Thierry Reding
From: Thierry Reding <[email protected]>
The Video Image Composer (VIC) 4.0 can be found on NVIDIA Tegra210 SoCs. It uses a different class (B0B6) that is slightly incompatible with the class found on earlier generations.
Signed-off-by Thierry Reding <[email protected]>--- tests/tegra/meson.build | 2 + tests/tegra/vic.c | 7 + tests/tegra/vic40.c | 370 ++++++++++++++++++++++++++++++++++++++++ tests/tegra/vic40.h | 285 +++++++++++++++++++++++++++++++ 4 files changed, 664 insertions(+)create mode 100644
tests/tegra/vic40.c
create mode 100644tests/tegra/vic40.htests/tegra/meson.build +2
-0@@ -36,6 +36,8 @@ libdrm_test_tegra = static_library( 'vic.h', 'vic30.c', 'vic30.h', + 'vic40.c', + 'vic40.h', ), config_file ], include_directories : [inc_root, inc_drm, inc_tegra], link_with : libdrm,tests/tegra/vic.c +7
-0@@ -134,6 +134,10 @@ void vic_image_dump(struct vic_image *image, FILE *fp)int vic30_new (struct drm_tegra *drm,struct drm_tegra_channel *channel,struct vic **vicp); +/* from vic40.c */ +int vic40_new (struct drm_tegra *drm,struct drm_tegra_channel *channel, +struct vic **vicp); +int vic_new (struct drm_tegra *drm,struct drm_tegra_channel *channel,struct vic **vicp) {@@ -144,6 +148,9 @@ int vic_new(struct drm_tegra *drm, struct drm_tegra_channel *channel,switch (version) {case 0x40 :return vic30_new (drm, channel, vicp); + +case 0x21 : +return vic40_new (drm, channel, vicp); }return -ENOTSUP ;tests/tegra/vic40.c new file +43
-0@@ -0,0 +1,370 @@ +/* +* Copyright © 2018 NVIDIA Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <errno.h> +#include <string.h> + +#include "private.h" +#include "tegra.h" +#include "vic.h" +#include "vic40.h" + +struct vic40 { +struct vic base; + +struct { +struct drm_tegra_mapping *map; +struct drm_tegra_bo *bo; + } config; + +struct { +struct drm_tegra_mapping *map; +struct drm_tegra_bo *bo; + } filter; +
Quoted 8 lines
tests/tegra/vic40.c line 48
Quoted 5 lines
tests/tegra/vic40.c new file +5
-0+struct { +struct drm_tegra_mapping *map; +struct drm_tegra_bo *bo; + } hist; +};Histogram buffer not necessary at least on VIC4.0 and later. (Same applies to VIC4.1 and VIC4.2 patches).
I'm pretty sure that I saw SMMU faults without this on all of Tegra210, Tegra186 and Tegra194. I'll go and test this once more.
Quoted 2 lines
Also not sure if it's worth duplicating all this for the very minor differences between VIC4.0/4.1/4.2?
In practice you would likely want to compress this a bit. However, as I mentioned before this is meant to serve as a reference implementation and therefore it's a bit more verbose than it would be in a more practical use-case.
Thierry
Re: [PATCH libdrm v2 20/25] tests: tegra: Add VIC 4.0 support
Quoted 112 lines · Thierry Reding
Quoted 102 lines · Mikko Perttunen
Quoted 101 lines · Thierry Reding
From: Thierry Reding <[email protected]>
The Video Image Composer (VIC) 4.0 can be found on NVIDIA Tegra210 SoCs. It uses a different class (B0B6) that is slightly incompatible with the class found on earlier generations.
Signed-off-by Thierry Reding <[email protected]>--- tests/tegra/meson.build | 2 + tests/tegra/vic.c | 7 + tests/tegra/vic40.c | 370 ++++++++++++++++++++++++++++++++++++++++ tests/tegra/vic40.h | 285 +++++++++++++++++++++++++++++++ 4 files changed, 664 insertions(+)create mode 100644
tests/tegra/vic40.c
create mode 100644tests/tegra/vic40.htests/tegra/meson.build +2
-0@@ -36,6 +36,8 @@ libdrm_test_tegra = static_library( 'vic.h', 'vic30.c', 'vic30.h', + 'vic40.c', + 'vic40.h', ), config_file ], include_directories : [inc_root, inc_drm, inc_tegra], link_with : libdrm,tests/tegra/vic.c +7
-0@@ -134,6 +134,10 @@ void vic_image_dump(struct vic_image *image, FILE *fp)int vic30_new (struct drm_tegra *drm,struct drm_tegra_channel *channel,struct vic **vicp); +/* from vic40.c */ +int vic40_new (struct drm_tegra *drm,struct drm_tegra_channel *channel, +struct vic **vicp); +int vic_new (struct drm_tegra *drm,struct drm_tegra_channel *channel,struct vic **vicp) {@@ -144,6 +148,9 @@ int vic_new(struct drm_tegra *drm, struct drm_tegra_channel *channel,switch (version) {case 0x40 :return vic30_new (drm, channel, vicp); + +case 0x21 : +return vic40_new (drm, channel, vicp); }return -ENOTSUP ;tests/tegra/vic40.c new file +43
-0@@ -0,0 +1,370 @@ +/* +* Copyright © 2018 NVIDIA Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include <errno.h> +#include <string.h> + +#include "private.h" +#include "tegra.h" +#include "vic.h" +#include "vic40.h" + +struct vic40 { +struct vic base; + +struct { +struct drm_tegra_mapping *map; +struct drm_tegra_bo *bo; + } config; + +struct { +struct drm_tegra_mapping *map; +struct drm_tegra_bo *bo; + } filter; +Quoted 8 lines
tests/tegra/vic40.c line 48
Quoted 5 lines
tests/tegra/vic40.c new file +5
-0+struct { +struct drm_tegra_mapping *map; +struct drm_tegra_bo *bo; + } hist; +};Histogram buffer not necessary at least on VIC4.0 and later. (Same applies to VIC4.1 and VIC4.2 patches).
Quoted 2 lines
I'm pretty sure that I saw SMMU faults without this on all of Tegra210, Tegra186 and Tegra194. I'll go and test this once more.
Nevermind, I see now that this buffer isn't used at all on VIC 4.0, 4.1 and 4.2. I misread your comment as this buffer not needing to be supplied in the command streams.
Removed all code related to that from the newer versions of VIC.
Thierry
PATCH v2 21/25 tests: tegra: Add VIC 4.1 support
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
The Video Image Composer (VIC) 4.1 can be found on NVIDIA Tegra186 SoCs. It uses a different class (B1B6) that is slightly incompatible with the class found on earlier generations.
--- tests/tegra/meson.build | 2 + tests/tegra/vic.c | 7 + tests/tegra/vic41.c | 374 ++++++++++++++++++++++++++++++++++++++++ tests/tegra/vic41.h | 372 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 755 insertions(+) create mode 100644 tests/tegra/vic41.c create mode 100644 tests/tegra/vic41.h
tests/tegra/meson.build +2 -0
@@ -38,6 +38,8 @@ libdrm_test_tegra = static_library( 'vic30.h', 'vic40.c', 'vic40.h', + 'vic41.c', + 'vic41.h', ), config_file ], include_directories : [inc_root, inc_drm, inc_tegra], link_with : libdrm,
tests/tegra/vic.c +7 -0
@@ -138,6 +138,10 @@ int vic30_new(struct drm_tegra *drm, struct drm_tegra_channel *channel,int vic40_new (struct drm_tegra *drm,struct drm_tegra_channel *channel,struct vic **vicp); +/* from vic41.c */ +int vic41_new (struct drm_tegra *drm,struct drm_tegra_channel *channel, +struct vic **vicp); +int vic_new (struct drm_tegra *drm,struct drm_tegra_channel *channel,struct vic **vicp) {
@@ -151,6 +155,9 @@ int vic_new(struct drm_tegra *drm, struct drm_tegra_channel *channel,case 0x21 :return vic40_new (drm, channel, vicp); + +case 0x18 : +return vic41_new (drm, channel, vicp); }return -ENOTSUP ;
tests/tegra/vic41.c new file +374 -0
374 lines not on this page · raw message
tests/tegra/vic41.h new file +372 -0
372 lines not on this page · raw message
Signature · 1 line
2.35.1
PATCH v2 22/25 tests: tegra: Add VIC 4.2 support
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
The Video Image Composer (VIC) 4.2 can be found on NVIDIA Tegra194 SoCs. It uses a different class (C5B6) that is slightly incompatible with the class found on earlier generations, although it is backwards compatible with the class implemented on Tegra186 (B1B6).
--- tests/tegra/meson.build | 2 + tests/tegra/vic.c | 7 + tests/tegra/vic42.c | 374 +++++++++++++++++++++++++ tests/tegra/vic42.h | 597 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 980 insertions(+) create mode 100644 tests/tegra/vic42.c create mode 100644 tests/tegra/vic42.h
tests/tegra/meson.build +2 -0
@@ -40,6 +40,8 @@ libdrm_test_tegra = static_library( 'vic40.h', 'vic41.c', 'vic41.h', + 'vic42.c', + 'vic42.h', ), config_file ], include_directories : [inc_root, inc_drm, inc_tegra], link_with : libdrm,
tests/tegra/vic.c +7 -0
@@ -142,6 +142,10 @@ int vic40_new(struct drm_tegra *drm, struct drm_tegra_channel *channel,int vic41_new (struct drm_tegra *drm,struct drm_tegra_channel *channel,struct vic **vicp); +/* from vic42.c */ +int vic42_new (struct drm_tegra *drm,struct drm_tegra_channel *channel, +struct vic **vicp); +int vic_new (struct drm_tegra *drm,struct drm_tegra_channel *channel,struct vic **vicp) {
@@ -158,6 +162,9 @@ int vic_new(struct drm_tegra *drm, struct drm_tegra_channel *channel,case 0x18 :return vic41_new (drm, channel, vicp); + +case 0x19 : +return vic42_new (drm, channel, vicp); }return -ENOTSUP ;
tests/tegra/vic42.c new file +374 -0
374 lines not on this page · raw message
tests/tegra/vic42.h new file +597 -0
597 lines not on this page · raw message
Signature · 1 line
2.35.1
PATCH v2 23/25 tests: tegra: Add VIC clear test
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
This test will attempt to use VIC to clear a surface.
--- tests/tegra/meson.build | 9 +++ tests/tegra/vic-clear.c | 173 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 182 insertions(+) create mode 100644 tests/tegra/vic-clear.c
tests/tegra/meson.build +9 -0
@@ -82,3 +82,12 @@ syncpt_timeout = executable( link_with : [libdrm, libdrm_tegra, libdrm_test, libdrm_test_tegra], install : with_install_tests, ) + +vic_clear = executable( + 'tegra-vic-clear', + files('vic-clear.c'), + include_directories : [inc_root, inc_drm, inc_tegra], + c_args : libdrm_c_args, + link_with : [libdrm, libdrm_tegra, libdrm_test, libdrm_test_tegra], + install : with_install_tests, +)
tests/tegra/vic-clear.c new file +173 -0
173 lines not on this page · raw message
Signature · 1 line
2.35.1
PATCH v2 24/25 tests: tegra: Add VIC blit test
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
This test will attempt to use the VIC to blit from one surface to another.
--- tests/tegra/meson.build | 9 ++ tests/tegra/vic-blit.c | 333 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 342 insertions(+) create mode 100644 tests/tegra/vic-blit.c
tests/tegra/meson.build +9 -0
@@ -91,3 +91,12 @@ vic_clear = executable( link_with : [libdrm, libdrm_tegra, libdrm_test, libdrm_test_tegra], install : with_install_tests, ) + +vic_blit = executable( + 'tegra-vic-blit', + files('vic-blit.c'), + include_directories : [inc_root, inc_drm, inc_tegra], + c_args : libdrm_c_args, + link_with : [libdrm, libdrm_tegra, libdrm_test, libdrm_test_tegra], + install : with_install_tests, +)
tests/tegra/vic-blit.c new file +333 -0
333 lines not on this page · raw message
Signature · 1 line
2.35.1
PATCH v2 25/25 tests: tegra: Add VIC flip test
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
This test will attempt to use the VIC to blit one surface to another and perform a vertical flip.
--- tests/tegra/meson.build | 9 ++ tests/tegra/vic-flip.c | 333 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 342 insertions(+) create mode 100644 tests/tegra/vic-flip.c
tests/tegra/meson.build +9 -0
@@ -100,3 +100,12 @@ vic_blit = executable( link_with : [libdrm, libdrm_tegra, libdrm_test, libdrm_test_tegra], install : with_install_tests, ) + +vic_flip = executable( + 'tegra-vic-flip', + files('vic-flip.c'), + include_directories : [inc_root, inc_drm, inc_tegra], + c_args : libdrm_c_args, + link_with : [libdrm, libdrm_tegra, libdrm_test, libdrm_test_tegra], + install : with_install_tests, +)
tests/tegra/vic-flip.c new file +333 -0
333 lines not on this page · raw message
Signature · 1 line
2.35.1