tree: Run clang-format to conform to the kernel coding style
The coding style has been a bit erratic. Enforce the linux kernel coding style by reusing their .clang-format file, running clang-format on the source, and ignoring the few shortcomings that clang-format has at the moment (especially on aligning the define values). Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
This commit is contained in:
+427
@@ -0,0 +1,427 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-2.0
|
||||||
|
#
|
||||||
|
# clang-format configuration file. Intended for clang-format >= 4.
|
||||||
|
#
|
||||||
|
# For more information, see:
|
||||||
|
#
|
||||||
|
# Documentation/process/clang-format.rst
|
||||||
|
# https://clang.llvm.org/docs/ClangFormat.html
|
||||||
|
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
|
||||||
|
#
|
||||||
|
---
|
||||||
|
AccessModifierOffset: -4
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
AlignConsecutiveAssignments: false
|
||||||
|
AlignConsecutiveDeclarations: false
|
||||||
|
AlignEscapedNewlines: Right
|
||||||
|
AlignOperands: true
|
||||||
|
AlignTrailingComments: false
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: false
|
||||||
|
AllowShortBlocksOnASingleLine: false
|
||||||
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: None
|
||||||
|
AllowShortIfStatementsOnASingleLine: false
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AlwaysBreakAfterDefinitionReturnType: None
|
||||||
|
AlwaysBreakAfterReturnType: None
|
||||||
|
AlwaysBreakBeforeMultilineStrings: false
|
||||||
|
AlwaysBreakTemplateDeclarations: false
|
||||||
|
BinPackArguments: true
|
||||||
|
BinPackParameters: true
|
||||||
|
BraceWrapping:
|
||||||
|
AfterClass: false
|
||||||
|
AfterControlStatement: false
|
||||||
|
AfterEnum: false
|
||||||
|
AfterFunction: true
|
||||||
|
AfterNamespace: true
|
||||||
|
AfterObjCDeclaration: false
|
||||||
|
AfterStruct: false
|
||||||
|
AfterUnion: false
|
||||||
|
#AfterExternBlock: false # Unknown to clang-format-5.0
|
||||||
|
BeforeCatch: false
|
||||||
|
BeforeElse: false
|
||||||
|
IndentBraces: false
|
||||||
|
#SplitEmptyFunction: true # Unknown to clang-format-4.0
|
||||||
|
#SplitEmptyRecord: true # Unknown to clang-format-4.0
|
||||||
|
#SplitEmptyNamespace: true # Unknown to clang-format-4.0
|
||||||
|
BreakBeforeBinaryOperators: None
|
||||||
|
BreakBeforeBraces: Custom
|
||||||
|
BreakBeforeInheritanceComma: false # Unknown to clang-format-4.0
|
||||||
|
BreakBeforeTernaryOperators: false
|
||||||
|
BreakConstructorInitializersBeforeComma: false
|
||||||
|
BreakConstructorInitializers: BeforeComma # Unknown to clang-format-4.0
|
||||||
|
BreakAfterJavaFieldAnnotations: false
|
||||||
|
BreakStringLiterals: false
|
||||||
|
ColumnLimit: 80
|
||||||
|
CommentPragmas: '^ IWYU pragma:'
|
||||||
|
CompactNamespaces: false # Unknown to clang-format-4.0
|
||||||
|
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||||
|
ConstructorInitializerIndentWidth: 8
|
||||||
|
ContinuationIndentWidth: 8
|
||||||
|
Cpp11BracedListStyle: false
|
||||||
|
DerivePointerAlignment: false
|
||||||
|
DisableFormat: false
|
||||||
|
ExperimentalAutoDetectBinPacking: false
|
||||||
|
FixNamespaceComments: false # Unknown to clang-format-4.0
|
||||||
|
|
||||||
|
# Taken from:
|
||||||
|
# git grep -h '^#define [^[:space:]]*for_each[^[:space:]]*(' include/ \
|
||||||
|
# | sed "s,^#define \([^[:space:]]*for_each[^[:space:]]*\)(.*$, - '\1'," \
|
||||||
|
# | sort | uniq
|
||||||
|
ForEachMacros:
|
||||||
|
- 'apei_estatus_for_each_section'
|
||||||
|
- 'ata_for_each_dev'
|
||||||
|
- 'ata_for_each_link'
|
||||||
|
- 'ax25_for_each'
|
||||||
|
- 'ax25_uid_for_each'
|
||||||
|
- 'bio_for_each_integrity_vec'
|
||||||
|
- '__bio_for_each_segment'
|
||||||
|
- 'bio_for_each_segment'
|
||||||
|
- 'bio_for_each_segment_all'
|
||||||
|
- 'bio_list_for_each'
|
||||||
|
- 'bip_for_each_vec'
|
||||||
|
- 'blkg_for_each_descendant_post'
|
||||||
|
- 'blkg_for_each_descendant_pre'
|
||||||
|
- 'blk_queue_for_each_rl'
|
||||||
|
- 'bond_for_each_slave'
|
||||||
|
- 'bond_for_each_slave_rcu'
|
||||||
|
- 'btree_for_each_safe128'
|
||||||
|
- 'btree_for_each_safe32'
|
||||||
|
- 'btree_for_each_safe64'
|
||||||
|
- 'btree_for_each_safel'
|
||||||
|
- 'card_for_each_dev'
|
||||||
|
- 'cgroup_taskset_for_each'
|
||||||
|
- 'cgroup_taskset_for_each_leader'
|
||||||
|
- 'cpufreq_for_each_entry'
|
||||||
|
- 'cpufreq_for_each_entry_idx'
|
||||||
|
- 'cpufreq_for_each_valid_entry'
|
||||||
|
- 'cpufreq_for_each_valid_entry_idx'
|
||||||
|
- 'css_for_each_child'
|
||||||
|
- 'css_for_each_descendant_post'
|
||||||
|
- 'css_for_each_descendant_pre'
|
||||||
|
- 'device_for_each_child_node'
|
||||||
|
- 'drm_atomic_crtc_for_each_plane'
|
||||||
|
- 'drm_atomic_crtc_state_for_each_plane'
|
||||||
|
- 'drm_atomic_crtc_state_for_each_plane_state'
|
||||||
|
- 'drm_for_each_connector_iter'
|
||||||
|
- 'drm_for_each_crtc'
|
||||||
|
- 'drm_for_each_encoder'
|
||||||
|
- 'drm_for_each_encoder_mask'
|
||||||
|
- 'drm_for_each_fb'
|
||||||
|
- 'drm_for_each_legacy_plane'
|
||||||
|
- 'drm_for_each_plane'
|
||||||
|
- 'drm_for_each_plane_mask'
|
||||||
|
- 'drm_mm_for_each_hole'
|
||||||
|
- 'drm_mm_for_each_node'
|
||||||
|
- 'drm_mm_for_each_node_in_range'
|
||||||
|
- 'drm_mm_for_each_node_safe'
|
||||||
|
- 'for_each_active_drhd_unit'
|
||||||
|
- 'for_each_active_iommu'
|
||||||
|
- 'for_each_available_child_of_node'
|
||||||
|
- 'for_each_bio'
|
||||||
|
- 'for_each_board_func_rsrc'
|
||||||
|
- 'for_each_bvec'
|
||||||
|
- 'for_each_child_of_node'
|
||||||
|
- 'for_each_clear_bit'
|
||||||
|
- 'for_each_clear_bit_from'
|
||||||
|
- 'for_each_cmsghdr'
|
||||||
|
- 'for_each_compatible_node'
|
||||||
|
- 'for_each_console'
|
||||||
|
- 'for_each_cpu'
|
||||||
|
- 'for_each_cpu_and'
|
||||||
|
- 'for_each_cpu_not'
|
||||||
|
- 'for_each_cpu_wrap'
|
||||||
|
- 'for_each_dev_addr'
|
||||||
|
- 'for_each_dma_cap_mask'
|
||||||
|
- 'for_each_drhd_unit'
|
||||||
|
- 'for_each_dss_dev'
|
||||||
|
- 'for_each_efi_memory_desc'
|
||||||
|
- 'for_each_efi_memory_desc_in_map'
|
||||||
|
- 'for_each_endpoint_of_node'
|
||||||
|
- 'for_each_evictable_lru'
|
||||||
|
- 'for_each_fib6_node_rt_rcu'
|
||||||
|
- 'for_each_fib6_walker_rt'
|
||||||
|
- 'for_each_free_mem_range'
|
||||||
|
- 'for_each_free_mem_range_reverse'
|
||||||
|
- 'for_each_func_rsrc'
|
||||||
|
- 'for_each_hstate'
|
||||||
|
- 'for_each_if'
|
||||||
|
- 'for_each_iommu'
|
||||||
|
- 'for_each_ip_tunnel_rcu'
|
||||||
|
- 'for_each_irq_nr'
|
||||||
|
- 'for_each_lru'
|
||||||
|
- 'for_each_matching_node'
|
||||||
|
- 'for_each_matching_node_and_match'
|
||||||
|
- 'for_each_memblock'
|
||||||
|
- 'for_each_memblock_type'
|
||||||
|
- 'for_each_memcg_cache_index'
|
||||||
|
- 'for_each_mem_pfn_range'
|
||||||
|
- 'for_each_mem_range'
|
||||||
|
- 'for_each_mem_range_rev'
|
||||||
|
- 'for_each_migratetype_order'
|
||||||
|
- 'for_each_msi_entry'
|
||||||
|
- 'for_each_net'
|
||||||
|
- 'for_each_netdev'
|
||||||
|
- 'for_each_netdev_continue'
|
||||||
|
- 'for_each_netdev_continue_rcu'
|
||||||
|
- 'for_each_netdev_feature'
|
||||||
|
- 'for_each_netdev_in_bond_rcu'
|
||||||
|
- 'for_each_netdev_rcu'
|
||||||
|
- 'for_each_netdev_reverse'
|
||||||
|
- 'for_each_netdev_safe'
|
||||||
|
- 'for_each_net_rcu'
|
||||||
|
- 'for_each_new_connector_in_state'
|
||||||
|
- 'for_each_new_crtc_in_state'
|
||||||
|
- 'for_each_new_plane_in_state'
|
||||||
|
- 'for_each_new_private_obj_in_state'
|
||||||
|
- 'for_each_node'
|
||||||
|
- 'for_each_node_by_name'
|
||||||
|
- 'for_each_node_by_type'
|
||||||
|
- 'for_each_node_mask'
|
||||||
|
- 'for_each_node_state'
|
||||||
|
- 'for_each_node_with_cpus'
|
||||||
|
- 'for_each_node_with_property'
|
||||||
|
- 'for_each_of_allnodes'
|
||||||
|
- 'for_each_of_allnodes_from'
|
||||||
|
- 'for_each_of_pci_range'
|
||||||
|
- 'for_each_old_connector_in_state'
|
||||||
|
- 'for_each_old_crtc_in_state'
|
||||||
|
- 'for_each_oldnew_connector_in_state'
|
||||||
|
- 'for_each_oldnew_crtc_in_state'
|
||||||
|
- 'for_each_oldnew_plane_in_state'
|
||||||
|
- 'for_each_oldnew_private_obj_in_state'
|
||||||
|
- 'for_each_old_plane_in_state'
|
||||||
|
- 'for_each_old_private_obj_in_state'
|
||||||
|
- 'for_each_online_cpu'
|
||||||
|
- 'for_each_online_node'
|
||||||
|
- 'for_each_online_pgdat'
|
||||||
|
- 'for_each_pci_bridge'
|
||||||
|
- 'for_each_pci_dev'
|
||||||
|
- 'for_each_pci_msi_entry'
|
||||||
|
- 'for_each_populated_zone'
|
||||||
|
- 'for_each_possible_cpu'
|
||||||
|
- 'for_each_present_cpu'
|
||||||
|
- 'for_each_prime_number'
|
||||||
|
- 'for_each_prime_number_from'
|
||||||
|
- 'for_each_process'
|
||||||
|
- 'for_each_process_thread'
|
||||||
|
- 'for_each_property_of_node'
|
||||||
|
- 'for_each_reserved_mem_region'
|
||||||
|
- 'for_each_resv_unavail_range'
|
||||||
|
- 'for_each_rtdcom'
|
||||||
|
- 'for_each_rtdcom_safe'
|
||||||
|
- 'for_each_set_bit'
|
||||||
|
- 'for_each_set_bit_from'
|
||||||
|
- 'for_each_sg'
|
||||||
|
- 'for_each_sg_page'
|
||||||
|
- '__for_each_thread'
|
||||||
|
- 'for_each_thread'
|
||||||
|
- 'for_each_zone'
|
||||||
|
- 'for_each_zone_zonelist'
|
||||||
|
- 'for_each_zone_zonelist_nodemask'
|
||||||
|
- 'fwnode_for_each_available_child_node'
|
||||||
|
- 'fwnode_for_each_child_node'
|
||||||
|
- 'fwnode_graph_for_each_endpoint'
|
||||||
|
- 'gadget_for_each_ep'
|
||||||
|
- 'hash_for_each'
|
||||||
|
- 'hash_for_each_possible'
|
||||||
|
- 'hash_for_each_possible_rcu'
|
||||||
|
- 'hash_for_each_possible_rcu_notrace'
|
||||||
|
- 'hash_for_each_possible_safe'
|
||||||
|
- 'hash_for_each_rcu'
|
||||||
|
- 'hash_for_each_safe'
|
||||||
|
- 'hctx_for_each_ctx'
|
||||||
|
- 'hlist_bl_for_each_entry'
|
||||||
|
- 'hlist_bl_for_each_entry_rcu'
|
||||||
|
- 'hlist_bl_for_each_entry_safe'
|
||||||
|
- 'hlist_for_each'
|
||||||
|
- 'hlist_for_each_entry'
|
||||||
|
- 'hlist_for_each_entry_continue'
|
||||||
|
- 'hlist_for_each_entry_continue_rcu'
|
||||||
|
- 'hlist_for_each_entry_continue_rcu_bh'
|
||||||
|
- 'hlist_for_each_entry_from'
|
||||||
|
- 'hlist_for_each_entry_from_rcu'
|
||||||
|
- 'hlist_for_each_entry_rcu'
|
||||||
|
- 'hlist_for_each_entry_rcu_bh'
|
||||||
|
- 'hlist_for_each_entry_rcu_notrace'
|
||||||
|
- 'hlist_for_each_entry_safe'
|
||||||
|
- '__hlist_for_each_rcu'
|
||||||
|
- 'hlist_for_each_safe'
|
||||||
|
- 'hlist_nulls_for_each_entry'
|
||||||
|
- 'hlist_nulls_for_each_entry_from'
|
||||||
|
- 'hlist_nulls_for_each_entry_rcu'
|
||||||
|
- 'hlist_nulls_for_each_entry_safe'
|
||||||
|
- 'ide_host_for_each_port'
|
||||||
|
- 'ide_port_for_each_dev'
|
||||||
|
- 'ide_port_for_each_present_dev'
|
||||||
|
- 'idr_for_each_entry'
|
||||||
|
- 'idr_for_each_entry_continue'
|
||||||
|
- 'idr_for_each_entry_ul'
|
||||||
|
- 'inet_bind_bucket_for_each'
|
||||||
|
- 'inet_lhash2_for_each_icsk_rcu'
|
||||||
|
- 'iov_for_each'
|
||||||
|
- 'key_for_each'
|
||||||
|
- 'key_for_each_safe'
|
||||||
|
- 'klp_for_each_func'
|
||||||
|
- 'klp_for_each_object'
|
||||||
|
- 'kvm_for_each_memslot'
|
||||||
|
- 'kvm_for_each_vcpu'
|
||||||
|
- 'list_for_each'
|
||||||
|
- 'list_for_each_entry'
|
||||||
|
- 'list_for_each_entry_continue'
|
||||||
|
- 'list_for_each_entry_continue_rcu'
|
||||||
|
- 'list_for_each_entry_continue_reverse'
|
||||||
|
- 'list_for_each_entry_from'
|
||||||
|
- 'list_for_each_entry_from_reverse'
|
||||||
|
- 'list_for_each_entry_lockless'
|
||||||
|
- 'list_for_each_entry_rcu'
|
||||||
|
- 'list_for_each_entry_reverse'
|
||||||
|
- 'list_for_each_entry_safe'
|
||||||
|
- 'list_for_each_entry_safe_continue'
|
||||||
|
- 'list_for_each_entry_safe_from'
|
||||||
|
- 'list_for_each_entry_safe_reverse'
|
||||||
|
- 'list_for_each_prev'
|
||||||
|
- 'list_for_each_prev_safe'
|
||||||
|
- 'list_for_each_safe'
|
||||||
|
- 'llist_for_each'
|
||||||
|
- 'llist_for_each_entry'
|
||||||
|
- 'llist_for_each_entry_safe'
|
||||||
|
- 'llist_for_each_safe'
|
||||||
|
- 'media_device_for_each_entity'
|
||||||
|
- 'media_device_for_each_intf'
|
||||||
|
- 'media_device_for_each_link'
|
||||||
|
- 'media_device_for_each_pad'
|
||||||
|
- 'netdev_for_each_lower_dev'
|
||||||
|
- 'netdev_for_each_lower_private'
|
||||||
|
- 'netdev_for_each_lower_private_rcu'
|
||||||
|
- 'netdev_for_each_mc_addr'
|
||||||
|
- 'netdev_for_each_uc_addr'
|
||||||
|
- 'netdev_for_each_upper_dev_rcu'
|
||||||
|
- 'netdev_hw_addr_list_for_each'
|
||||||
|
- 'nft_rule_for_each_expr'
|
||||||
|
- 'nla_for_each_attr'
|
||||||
|
- 'nla_for_each_nested'
|
||||||
|
- 'nlmsg_for_each_attr'
|
||||||
|
- 'nlmsg_for_each_msg'
|
||||||
|
- 'nr_neigh_for_each'
|
||||||
|
- 'nr_neigh_for_each_safe'
|
||||||
|
- 'nr_node_for_each'
|
||||||
|
- 'nr_node_for_each_safe'
|
||||||
|
- 'of_for_each_phandle'
|
||||||
|
- 'of_property_for_each_string'
|
||||||
|
- 'of_property_for_each_u32'
|
||||||
|
- 'pci_bus_for_each_resource'
|
||||||
|
- 'ping_portaddr_for_each_entry'
|
||||||
|
- 'plist_for_each'
|
||||||
|
- 'plist_for_each_continue'
|
||||||
|
- 'plist_for_each_entry'
|
||||||
|
- 'plist_for_each_entry_continue'
|
||||||
|
- 'plist_for_each_entry_safe'
|
||||||
|
- 'plist_for_each_safe'
|
||||||
|
- 'pnp_for_each_card'
|
||||||
|
- 'pnp_for_each_dev'
|
||||||
|
- 'protocol_for_each_card'
|
||||||
|
- 'protocol_for_each_dev'
|
||||||
|
- 'queue_for_each_hw_ctx'
|
||||||
|
- 'radix_tree_for_each_contig'
|
||||||
|
- 'radix_tree_for_each_slot'
|
||||||
|
- 'radix_tree_for_each_tagged'
|
||||||
|
- 'rbtree_postorder_for_each_entry_safe'
|
||||||
|
- 'resource_list_for_each_entry'
|
||||||
|
- 'resource_list_for_each_entry_safe'
|
||||||
|
- 'rhl_for_each_entry_rcu'
|
||||||
|
- 'rhl_for_each_rcu'
|
||||||
|
- 'rht_for_each'
|
||||||
|
- 'rht_for_each_continue'
|
||||||
|
- 'rht_for_each_entry'
|
||||||
|
- 'rht_for_each_entry_continue'
|
||||||
|
- 'rht_for_each_entry_rcu'
|
||||||
|
- 'rht_for_each_entry_rcu_continue'
|
||||||
|
- 'rht_for_each_entry_safe'
|
||||||
|
- 'rht_for_each_rcu'
|
||||||
|
- 'rht_for_each_rcu_continue'
|
||||||
|
- '__rq_for_each_bio'
|
||||||
|
- 'rq_for_each_segment'
|
||||||
|
- 'scsi_for_each_prot_sg'
|
||||||
|
- 'scsi_for_each_sg'
|
||||||
|
- 'sctp_for_each_hentry'
|
||||||
|
- 'sctp_skb_for_each'
|
||||||
|
- 'shdma_for_each_chan'
|
||||||
|
- '__shost_for_each_device'
|
||||||
|
- 'shost_for_each_device'
|
||||||
|
- 'sk_for_each'
|
||||||
|
- 'sk_for_each_bound'
|
||||||
|
- 'sk_for_each_entry_offset_rcu'
|
||||||
|
- 'sk_for_each_from'
|
||||||
|
- 'sk_for_each_rcu'
|
||||||
|
- 'sk_for_each_safe'
|
||||||
|
- 'sk_nulls_for_each'
|
||||||
|
- 'sk_nulls_for_each_from'
|
||||||
|
- 'sk_nulls_for_each_rcu'
|
||||||
|
- 'snd_pcm_group_for_each_entry'
|
||||||
|
- 'snd_soc_dapm_widget_for_each_path'
|
||||||
|
- 'snd_soc_dapm_widget_for_each_path_safe'
|
||||||
|
- 'snd_soc_dapm_widget_for_each_sink_path'
|
||||||
|
- 'snd_soc_dapm_widget_for_each_source_path'
|
||||||
|
- 'tb_property_for_each'
|
||||||
|
- 'udp_portaddr_for_each_entry'
|
||||||
|
- 'udp_portaddr_for_each_entry_rcu'
|
||||||
|
- 'usb_hub_for_each_child'
|
||||||
|
- 'v4l2_device_for_each_subdev'
|
||||||
|
- 'v4l2_m2m_for_each_dst_buf'
|
||||||
|
- 'v4l2_m2m_for_each_dst_buf_safe'
|
||||||
|
- 'v4l2_m2m_for_each_src_buf'
|
||||||
|
- 'v4l2_m2m_for_each_src_buf_safe'
|
||||||
|
- 'zorro_for_each_dev'
|
||||||
|
|
||||||
|
IncludeBlocks: Preserve # Unknown to clang-format-5.0
|
||||||
|
IncludeCategories:
|
||||||
|
- Regex: '.*'
|
||||||
|
Priority: 1
|
||||||
|
IncludeIsMainRegex: '(Test)?$'
|
||||||
|
IndentCaseLabels: false
|
||||||
|
IndentPPDirectives: None # Unknown to clang-format-5.0
|
||||||
|
IndentWidth: 8
|
||||||
|
IndentWrappedFunctionNames: true
|
||||||
|
JavaScriptQuotes: Leave
|
||||||
|
JavaScriptWrapImports: true
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||||
|
MacroBlockBegin: ''
|
||||||
|
MacroBlockEnd: ''
|
||||||
|
MaxEmptyLinesToKeep: 1
|
||||||
|
NamespaceIndentation: Inner
|
||||||
|
ObjCBlockIndentWidth: 8
|
||||||
|
ObjCSpaceAfterProperty: true
|
||||||
|
ObjCSpaceBeforeProtocolList: true
|
||||||
|
|
||||||
|
# Taken from git's rules
|
||||||
|
PenaltyBreakAssignment: 10 # Unknown to clang-format-4.0
|
||||||
|
PenaltyBreakBeforeFirstCallParameter: 30
|
||||||
|
PenaltyBreakComment: 10
|
||||||
|
PenaltyBreakFirstLessLess: 0
|
||||||
|
PenaltyBreakString: 10
|
||||||
|
PenaltyExcessCharacter: 100
|
||||||
|
PenaltyReturnTypeOnItsOwnLine: 60
|
||||||
|
|
||||||
|
PointerAlignment: Right
|
||||||
|
ReflowComments: false
|
||||||
|
SortIncludes: true
|
||||||
|
SortUsingDeclarations: false # Unknown to clang-format-4.0
|
||||||
|
SpaceAfterCStyleCast: false
|
||||||
|
SpaceAfterTemplateKeyword: true
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
# SpaceBeforeCtorInitializerColon: true # Unknown to clang-format-5.0
|
||||||
|
# SpaceBeforeInheritanceColon: true # Unknown to clang-format-5.0
|
||||||
|
SpaceBeforeParens: ControlStatements
|
||||||
|
# SpaceBeforeRangeBasedForLoopColon: true # Unknown to clang-format-5.0
|
||||||
|
SpaceInEmptyParentheses: false
|
||||||
|
SpacesBeforeTrailingComments: 1
|
||||||
|
SpacesInAngles: false
|
||||||
|
SpacesInContainerLiterals: false
|
||||||
|
SpacesInCStyleCastParentheses: false
|
||||||
|
SpacesInParentheses: false
|
||||||
|
SpacesInSquareBrackets: false
|
||||||
|
Standard: Cpp03
|
||||||
|
TabWidth: 8
|
||||||
|
UseTab: Always
|
||||||
|
...
|
||||||
+22
-17
@@ -23,16 +23,16 @@
|
|||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sunxi_cedrus.h"
|
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
#include "context.h"
|
#include "context.h"
|
||||||
|
#include "sunxi_cedrus.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
|
||||||
#include <linux/videodev2.h>
|
#include <linux/videodev2.h>
|
||||||
|
|
||||||
@@ -40,11 +40,12 @@
|
|||||||
#include "v4l2.h"
|
#include "v4l2.h"
|
||||||
|
|
||||||
VAStatus SunxiCedrusCreateBuffer(VADriverContextP context,
|
VAStatus SunxiCedrusCreateBuffer(VADriverContextP context,
|
||||||
VAContextID context_id, VABufferType type, unsigned int size,
|
VAContextID context_id, VABufferType type,
|
||||||
unsigned int count, void *data, VABufferID *buffer_id)
|
unsigned int size, unsigned int count,
|
||||||
|
void *data, VABufferID *buffer_id)
|
||||||
{
|
{
|
||||||
struct cedrus_data *driver_data =
|
struct cedrus_data *driver_data =
|
||||||
(struct cedrus_data *) context->pDriverData;
|
(struct cedrus_data *)context->pDriverData;
|
||||||
struct object_buffer *buffer_object = NULL;
|
struct object_buffer *buffer_object = NULL;
|
||||||
void *buffer_data;
|
void *buffer_data;
|
||||||
VAStatus status;
|
VAStatus status;
|
||||||
@@ -92,17 +93,18 @@ VAStatus SunxiCedrusCreateBuffer(VADriverContextP context,
|
|||||||
|
|
||||||
error:
|
error:
|
||||||
if (buffer_object != NULL)
|
if (buffer_object != NULL)
|
||||||
object_heap_free(&driver_data->buffer_heap, (struct object_base *) buffer_object);
|
object_heap_free(&driver_data->buffer_heap,
|
||||||
|
(struct object_base *)buffer_object);
|
||||||
|
|
||||||
complete:
|
complete:
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusDestroyBuffer(VADriverContextP context,
|
VAStatus SunxiCedrusDestroyBuffer(VADriverContextP context,
|
||||||
VABufferID buffer_id)
|
VABufferID buffer_id)
|
||||||
{
|
{
|
||||||
struct cedrus_data *driver_data =
|
struct cedrus_data *driver_data =
|
||||||
(struct cedrus_data *) context->pDriverData;
|
(struct cedrus_data *)context->pDriverData;
|
||||||
struct object_buffer *buffer_object;
|
struct object_buffer *buffer_object;
|
||||||
|
|
||||||
buffer_object = BUFFER(driver_data, buffer_id);
|
buffer_object = BUFFER(driver_data, buffer_id);
|
||||||
@@ -112,16 +114,17 @@ VAStatus SunxiCedrusDestroyBuffer(VADriverContextP context,
|
|||||||
if (buffer_object->data != NULL)
|
if (buffer_object->data != NULL)
|
||||||
free(buffer_object->data);
|
free(buffer_object->data);
|
||||||
|
|
||||||
object_heap_free(&driver_data->buffer_heap, (struct object_base *) buffer_object);
|
object_heap_free(&driver_data->buffer_heap,
|
||||||
|
(struct object_base *)buffer_object);
|
||||||
|
|
||||||
return VA_STATUS_SUCCESS;
|
return VA_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusMapBuffer(VADriverContextP context, VABufferID buffer_id,
|
VAStatus SunxiCedrusMapBuffer(VADriverContextP context, VABufferID buffer_id,
|
||||||
void **data_map)
|
void **data_map)
|
||||||
{
|
{
|
||||||
struct cedrus_data *driver_data =
|
struct cedrus_data *driver_data =
|
||||||
(struct cedrus_data *) context->pDriverData;
|
(struct cedrus_data *)context->pDriverData;
|
||||||
struct object_buffer *buffer_object;
|
struct object_buffer *buffer_object;
|
||||||
|
|
||||||
buffer_object = BUFFER(driver_data, buffer_id);
|
buffer_object = BUFFER(driver_data, buffer_id);
|
||||||
@@ -137,7 +140,7 @@ VAStatus SunxiCedrusMapBuffer(VADriverContextP context, VABufferID buffer_id,
|
|||||||
VAStatus SunxiCedrusUnmapBuffer(VADriverContextP context, VABufferID buffer_id)
|
VAStatus SunxiCedrusUnmapBuffer(VADriverContextP context, VABufferID buffer_id)
|
||||||
{
|
{
|
||||||
struct cedrus_data *driver_data =
|
struct cedrus_data *driver_data =
|
||||||
(struct cedrus_data *) context->pDriverData;
|
(struct cedrus_data *)context->pDriverData;
|
||||||
struct object_buffer *buffer_object;
|
struct object_buffer *buffer_object;
|
||||||
|
|
||||||
buffer_object = BUFFER(driver_data, buffer_id);
|
buffer_object = BUFFER(driver_data, buffer_id);
|
||||||
@@ -150,10 +153,11 @@ VAStatus SunxiCedrusUnmapBuffer(VADriverContextP context, VABufferID buffer_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusBufferSetNumElements(VADriverContextP context,
|
VAStatus SunxiCedrusBufferSetNumElements(VADriverContextP context,
|
||||||
VABufferID buffer_id, unsigned int count)
|
VABufferID buffer_id,
|
||||||
|
unsigned int count)
|
||||||
{
|
{
|
||||||
struct cedrus_data *driver_data =
|
struct cedrus_data *driver_data =
|
||||||
(struct cedrus_data *) context->pDriverData;
|
(struct cedrus_data *)context->pDriverData;
|
||||||
struct object_buffer *buffer_object;
|
struct object_buffer *buffer_object;
|
||||||
|
|
||||||
buffer_object = BUFFER(driver_data, buffer_id);
|
buffer_object = BUFFER(driver_data, buffer_id);
|
||||||
@@ -169,10 +173,11 @@ VAStatus SunxiCedrusBufferSetNumElements(VADriverContextP context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusBufferInfo(VADriverContextP context, VABufferID buffer_id,
|
VAStatus SunxiCedrusBufferInfo(VADriverContextP context, VABufferID buffer_id,
|
||||||
VABufferType *type, unsigned int *size, unsigned int *count)
|
VABufferType *type, unsigned int *size,
|
||||||
|
unsigned int *count)
|
||||||
{
|
{
|
||||||
struct cedrus_data *driver_data =
|
struct cedrus_data *driver_data =
|
||||||
(struct cedrus_data *) context->pDriverData;
|
(struct cedrus_data *)context->pDriverData;
|
||||||
struct object_buffer *buffer_object;
|
struct object_buffer *buffer_object;
|
||||||
|
|
||||||
buffer_object = BUFFER(driver_data, buffer_id);
|
buffer_object = BUFFER(driver_data, buffer_id);
|
||||||
|
|||||||
+12
-8
@@ -31,7 +31,8 @@
|
|||||||
#include "object_heap.h"
|
#include "object_heap.h"
|
||||||
#include "sunxi_cedrus.h"
|
#include "sunxi_cedrus.h"
|
||||||
|
|
||||||
#define BUFFER(data, id) ((struct object_buffer *) object_heap_lookup(&(data)->buffer_heap, id))
|
#define BUFFER(data, id) \
|
||||||
|
((struct object_buffer *)object_heap_lookup(&(data)->buffer_heap, id))
|
||||||
#define BUFFER_ID_OFFSET 0x08000000
|
#define BUFFER_ID_OFFSET 0x08000000
|
||||||
|
|
||||||
struct object_buffer {
|
struct object_buffer {
|
||||||
@@ -46,18 +47,21 @@ struct object_buffer {
|
|||||||
};
|
};
|
||||||
|
|
||||||
VAStatus SunxiCedrusCreateBuffer(VADriverContextP context,
|
VAStatus SunxiCedrusCreateBuffer(VADriverContextP context,
|
||||||
VAContextID context_id, VABufferType type, unsigned int size,
|
VAContextID context_id, VABufferType type,
|
||||||
unsigned int count, void *data, VABufferID *buffer_id);
|
unsigned int size, unsigned int count,
|
||||||
|
void *data, VABufferID *buffer_id);
|
||||||
void sunxi_cedrus_destroy_buffer(struct cedrus_data *driver_data,
|
void sunxi_cedrus_destroy_buffer(struct cedrus_data *driver_data,
|
||||||
struct object_buffer *obj_buffer);
|
struct object_buffer *obj_buffer);
|
||||||
VAStatus SunxiCedrusDestroyBuffer(VADriverContextP context,
|
VAStatus SunxiCedrusDestroyBuffer(VADriverContextP context,
|
||||||
VABufferID buffer_id);
|
VABufferID buffer_id);
|
||||||
VAStatus SunxiCedrusMapBuffer(VADriverContextP context, VABufferID buffer_id,
|
VAStatus SunxiCedrusMapBuffer(VADriverContextP context, VABufferID buffer_id,
|
||||||
void **data_map);
|
void **data_map);
|
||||||
VAStatus SunxiCedrusUnmapBuffer(VADriverContextP context, VABufferID buffer_id);
|
VAStatus SunxiCedrusUnmapBuffer(VADriverContextP context, VABufferID buffer_id);
|
||||||
VAStatus SunxiCedrusBufferSetNumElements(VADriverContextP context,
|
VAStatus SunxiCedrusBufferSetNumElements(VADriverContextP context,
|
||||||
VABufferID buffer_id, unsigned int count);
|
VABufferID buffer_id,
|
||||||
|
unsigned int count);
|
||||||
VAStatus SunxiCedrusBufferInfo(VADriverContextP context, VABufferID buffer_id,
|
VAStatus SunxiCedrusBufferInfo(VADriverContextP context, VABufferID buffer_id,
|
||||||
VABufferType *type, unsigned int *size, unsigned int *count);
|
VABufferType *type, unsigned int *size,
|
||||||
|
unsigned int *count);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+41
-23
@@ -23,8 +23,8 @@
|
|||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sunxi_cedrus.h"
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "sunxi_cedrus.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -33,15 +33,16 @@
|
|||||||
|
|
||||||
#include <linux/videodev2.h>
|
#include <linux/videodev2.h>
|
||||||
|
|
||||||
#include "v4l2.h"
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "v4l2.h"
|
||||||
|
|
||||||
VAStatus SunxiCedrusCreateConfig(VADriverContextP context, VAProfile profile,
|
VAStatus SunxiCedrusCreateConfig(VADriverContextP context, VAProfile profile,
|
||||||
VAEntrypoint entrypoint, VAConfigAttrib *attributes,
|
VAEntrypoint entrypoint,
|
||||||
int attributes_count, VAConfigID *config_id)
|
VAConfigAttrib *attributes,
|
||||||
|
int attributes_count, VAConfigID *config_id)
|
||||||
{
|
{
|
||||||
struct cedrus_data *driver_data =
|
struct cedrus_data *driver_data =
|
||||||
(struct cedrus_data *) context->pDriverData;
|
(struct cedrus_data *)context->pDriverData;
|
||||||
struct object_config *config_object;
|
struct object_config *config_object;
|
||||||
VAConfigID id;
|
VAConfigID id;
|
||||||
int i, index;
|
int i, index;
|
||||||
@@ -79,7 +80,8 @@ VAStatus SunxiCedrusCreateConfig(VADriverContextP context, VAProfile profile,
|
|||||||
for (i = 1; i < attributes_count; i++) {
|
for (i = 1; i < attributes_count; i++) {
|
||||||
index = config_object->attributes_count++;
|
index = config_object->attributes_count++;
|
||||||
config_object->attributes[index].type = attributes[index].type;
|
config_object->attributes[index].type = attributes[index].type;
|
||||||
config_object->attributes[index].value = attributes[index].value;
|
config_object->attributes[index].value =
|
||||||
|
attributes[index].value;
|
||||||
}
|
}
|
||||||
|
|
||||||
*config_id = id;
|
*config_id = id;
|
||||||
@@ -88,36 +90,42 @@ VAStatus SunxiCedrusCreateConfig(VADriverContextP context, VAProfile profile,
|
|||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusDestroyConfig(VADriverContextP context,
|
VAStatus SunxiCedrusDestroyConfig(VADriverContextP context,
|
||||||
VAConfigID config_id)
|
VAConfigID config_id)
|
||||||
{
|
{
|
||||||
struct cedrus_data *driver_data =
|
struct cedrus_data *driver_data =
|
||||||
(struct cedrus_data *) context->pDriverData;
|
(struct cedrus_data *)context->pDriverData;
|
||||||
struct object_config *config_object;
|
struct object_config *config_object;
|
||||||
|
|
||||||
config_object = CONFIG(driver_data, config_id);
|
config_object = CONFIG(driver_data, config_id);
|
||||||
if (config_object == NULL)
|
if (config_object == NULL)
|
||||||
return VA_STATUS_ERROR_INVALID_CONFIG;
|
return VA_STATUS_ERROR_INVALID_CONFIG;
|
||||||
|
|
||||||
object_heap_free(&driver_data->config_heap, (struct object_base *) config_object);
|
object_heap_free(&driver_data->config_heap,
|
||||||
|
(struct object_base *)config_object);
|
||||||
|
|
||||||
return VA_STATUS_SUCCESS;
|
return VA_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusQueryConfigProfiles(VADriverContextP context,
|
VAStatus SunxiCedrusQueryConfigProfiles(VADriverContextP context,
|
||||||
VAProfile *profiles, int *profiles_count)
|
VAProfile *profiles,
|
||||||
|
int *profiles_count)
|
||||||
{
|
{
|
||||||
struct cedrus_data *driver_data =
|
struct cedrus_data *driver_data =
|
||||||
(struct cedrus_data *) context->pDriverData;
|
(struct cedrus_data *)context->pDriverData;
|
||||||
unsigned int index = 0;
|
unsigned int index = 0;
|
||||||
bool found;
|
bool found;
|
||||||
|
|
||||||
found = v4l2_find_format(driver_data->video_fd, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, V4L2_PIX_FMT_MPEG2_SLICE);
|
found = v4l2_find_format(driver_data->video_fd,
|
||||||
|
V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
|
||||||
|
V4L2_PIX_FMT_MPEG2_SLICE);
|
||||||
if (found && index < (SUNXI_CEDRUS_MAX_CONFIG_ATTRIBUTES - 2)) {
|
if (found && index < (SUNXI_CEDRUS_MAX_CONFIG_ATTRIBUTES - 2)) {
|
||||||
profiles[index++] = VAProfileMPEG2Simple;
|
profiles[index++] = VAProfileMPEG2Simple;
|
||||||
profiles[index++] = VAProfileMPEG2Main;
|
profiles[index++] = VAProfileMPEG2Main;
|
||||||
}
|
}
|
||||||
|
|
||||||
found = v4l2_find_format(driver_data->video_fd, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, V4L2_PIX_FMT_H264_SLICE);
|
found = v4l2_find_format(driver_data->video_fd,
|
||||||
|
V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
|
||||||
|
V4L2_PIX_FMT_H264_SLICE);
|
||||||
if (found && index < (SUNXI_CEDRUS_MAX_CONFIG_ATTRIBUTES - 5)) {
|
if (found && index < (SUNXI_CEDRUS_MAX_CONFIG_ATTRIBUTES - 5)) {
|
||||||
profiles[index++] = VAProfileH264Main;
|
profiles[index++] = VAProfileH264Main;
|
||||||
profiles[index++] = VAProfileH264High;
|
profiles[index++] = VAProfileH264High;
|
||||||
@@ -132,7 +140,9 @@ VAStatus SunxiCedrusQueryConfigProfiles(VADriverContextP context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusQueryConfigEntrypoints(VADriverContextP context,
|
VAStatus SunxiCedrusQueryConfigEntrypoints(VADriverContextP context,
|
||||||
VAProfile profile, VAEntrypoint *entrypoints, int *entrypoints_count)
|
VAProfile profile,
|
||||||
|
VAEntrypoint *entrypoints,
|
||||||
|
int *entrypoints_count)
|
||||||
{
|
{
|
||||||
switch (profile) {
|
switch (profile) {
|
||||||
case VAProfileMPEG2Simple:
|
case VAProfileMPEG2Simple:
|
||||||
@@ -155,11 +165,14 @@ VAStatus SunxiCedrusQueryConfigEntrypoints(VADriverContextP context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusQueryConfigAttributes(VADriverContextP context,
|
VAStatus SunxiCedrusQueryConfigAttributes(VADriverContextP context,
|
||||||
VAConfigID config_id, VAProfile *profile, VAEntrypoint *entrypoint,
|
VAConfigID config_id,
|
||||||
VAConfigAttrib *attributes, int *attributes_count)
|
VAProfile *profile,
|
||||||
|
VAEntrypoint *entrypoint,
|
||||||
|
VAConfigAttrib *attributes,
|
||||||
|
int *attributes_count)
|
||||||
{
|
{
|
||||||
struct cedrus_data *driver_data =
|
struct cedrus_data *driver_data =
|
||||||
(struct cedrus_data *) context->pDriverData;
|
(struct cedrus_data *)context->pDriverData;
|
||||||
struct object_config *config_object;
|
struct object_config *config_object;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -174,7 +187,7 @@ VAStatus SunxiCedrusQueryConfigAttributes(VADriverContextP context,
|
|||||||
*entrypoint = config_object->entrypoint;
|
*entrypoint = config_object->entrypoint;
|
||||||
|
|
||||||
if (attributes_count != NULL)
|
if (attributes_count != NULL)
|
||||||
*attributes_count = config_object->attributes_count;
|
*attributes_count = config_object->attributes_count;
|
||||||
|
|
||||||
/* Attributes might be NULL to retrieve the associated count. */
|
/* Attributes might be NULL to retrieve the associated count. */
|
||||||
if (attributes != NULL)
|
if (attributes != NULL)
|
||||||
@@ -185,8 +198,10 @@ VAStatus SunxiCedrusQueryConfigAttributes(VADriverContextP context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusGetConfigAttributes(VADriverContextP context,
|
VAStatus SunxiCedrusGetConfigAttributes(VADriverContextP context,
|
||||||
VAProfile profile, VAEntrypoint entrypoint, VAConfigAttrib *attributes,
|
VAProfile profile,
|
||||||
int attributes_count)
|
VAEntrypoint entrypoint,
|
||||||
|
VAConfigAttrib *attributes,
|
||||||
|
int attributes_count)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
@@ -205,19 +220,22 @@ VAStatus SunxiCedrusGetConfigAttributes(VADriverContextP context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusQueryDisplayAttributes(VADriverContextP context,
|
VAStatus SunxiCedrusQueryDisplayAttributes(VADriverContextP context,
|
||||||
VADisplayAttribute *attributes, int *attributes_count)
|
VADisplayAttribute *attributes,
|
||||||
|
int *attributes_count)
|
||||||
{
|
{
|
||||||
return VA_STATUS_ERROR_UNIMPLEMENTED;
|
return VA_STATUS_ERROR_UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusGetDisplayAttributes(VADriverContextP context,
|
VAStatus SunxiCedrusGetDisplayAttributes(VADriverContextP context,
|
||||||
VADisplayAttribute *attributes, int attributes_count)
|
VADisplayAttribute *attributes,
|
||||||
|
int attributes_count)
|
||||||
{
|
{
|
||||||
return VA_STATUS_ERROR_UNIMPLEMENTED;
|
return VA_STATUS_ERROR_UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusSetDisplayAttributes(VADriverContextP context,
|
VAStatus SunxiCedrusSetDisplayAttributes(VADriverContextP context,
|
||||||
VADisplayAttribute *attributes, int attributes_count)
|
VADisplayAttribute *attributes,
|
||||||
|
int attributes_count)
|
||||||
{
|
{
|
||||||
return VA_STATUS_ERROR_UNIMPLEMENTED;
|
return VA_STATUS_ERROR_UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|||||||
+26
-13
@@ -31,7 +31,8 @@
|
|||||||
#include "object_heap.h"
|
#include "object_heap.h"
|
||||||
#include "sunxi_cedrus.h"
|
#include "sunxi_cedrus.h"
|
||||||
|
|
||||||
#define CONFIG(data, id) ((struct object_config *) object_heap_lookup(&(data)->config_heap, id))
|
#define CONFIG(data, id) \
|
||||||
|
((struct object_config *)object_heap_lookup(&(data)->config_heap, id))
|
||||||
#define CONFIG_ID_OFFSET 0x01000000
|
#define CONFIG_ID_OFFSET 0x01000000
|
||||||
|
|
||||||
struct object_config {
|
struct object_config {
|
||||||
@@ -44,25 +45,37 @@ struct object_config {
|
|||||||
};
|
};
|
||||||
|
|
||||||
VAStatus SunxiCedrusCreateConfig(VADriverContextP context, VAProfile profile,
|
VAStatus SunxiCedrusCreateConfig(VADriverContextP context, VAProfile profile,
|
||||||
VAEntrypoint entrypoint, VAConfigAttrib *attributes,
|
VAEntrypoint entrypoint,
|
||||||
int attributes_count, VAConfigID *config_id);
|
VAConfigAttrib *attributes,
|
||||||
|
int attributes_count, VAConfigID *config_id);
|
||||||
VAStatus SunxiCedrusDestroyConfig(VADriverContextP context,
|
VAStatus SunxiCedrusDestroyConfig(VADriverContextP context,
|
||||||
VAConfigID config_id);
|
VAConfigID config_id);
|
||||||
VAStatus SunxiCedrusQueryConfigProfiles(VADriverContextP context,
|
VAStatus SunxiCedrusQueryConfigProfiles(VADriverContextP context,
|
||||||
VAProfile *profiles, int *profiles_count);
|
VAProfile *profiles,
|
||||||
|
int *profiles_count);
|
||||||
VAStatus SunxiCedrusQueryConfigEntrypoints(VADriverContextP context,
|
VAStatus SunxiCedrusQueryConfigEntrypoints(VADriverContextP context,
|
||||||
VAProfile profile, VAEntrypoint *entrypoints, int *entrypoints_count);
|
VAProfile profile,
|
||||||
|
VAEntrypoint *entrypoints,
|
||||||
|
int *entrypoints_count);
|
||||||
VAStatus SunxiCedrusQueryConfigAttributes(VADriverContextP context,
|
VAStatus SunxiCedrusQueryConfigAttributes(VADriverContextP context,
|
||||||
VAConfigID config_id, VAProfile *profile, VAEntrypoint *entrypoint,
|
VAConfigID config_id,
|
||||||
VAConfigAttrib *attributes, int *attributes_count);
|
VAProfile *profile,
|
||||||
|
VAEntrypoint *entrypoint,
|
||||||
|
VAConfigAttrib *attributes,
|
||||||
|
int *attributes_count);
|
||||||
VAStatus SunxiCedrusGetConfigAttributes(VADriverContextP context,
|
VAStatus SunxiCedrusGetConfigAttributes(VADriverContextP context,
|
||||||
VAProfile profile, VAEntrypoint entrypoint, VAConfigAttrib *attributes,
|
VAProfile profile,
|
||||||
int attributes_count);
|
VAEntrypoint entrypoint,
|
||||||
|
VAConfigAttrib *attributes,
|
||||||
|
int attributes_count);
|
||||||
VAStatus SunxiCedrusQueryDisplayAttributes(VADriverContextP context,
|
VAStatus SunxiCedrusQueryDisplayAttributes(VADriverContextP context,
|
||||||
VADisplayAttribute *attributes, int *attributes_count);
|
VADisplayAttribute *attributes,
|
||||||
|
int *attributes_count);
|
||||||
VAStatus SunxiCedrusGetDisplayAttributes(VADriverContextP context,
|
VAStatus SunxiCedrusGetDisplayAttributes(VADriverContextP context,
|
||||||
VADisplayAttribute *attributes, int attributes_count);
|
VADisplayAttribute *attributes,
|
||||||
|
int attributes_count);
|
||||||
VAStatus SunxiCedrusSetDisplayAttributes(VADriverContextP context,
|
VAStatus SunxiCedrusSetDisplayAttributes(VADriverContextP context,
|
||||||
VADisplayAttribute *attributes, int attributes_count);
|
VADisplayAttribute *attributes,
|
||||||
|
int attributes_count);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+32
-18
@@ -23,9 +23,9 @@
|
|||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sunxi_cedrus.h"
|
|
||||||
#include "context.h"
|
#include "context.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "sunxi_cedrus.h"
|
||||||
#include "surface.h"
|
#include "surface.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -38,16 +38,17 @@
|
|||||||
|
|
||||||
#include <linux/videodev2.h>
|
#include <linux/videodev2.h>
|
||||||
|
|
||||||
#include "v4l2.h"
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "v4l2.h"
|
||||||
|
|
||||||
VAStatus SunxiCedrusCreateContext(VADriverContextP context,
|
VAStatus SunxiCedrusCreateContext(VADriverContextP context,
|
||||||
VAConfigID config_id, int picture_width, int picture_height, int flags,
|
VAConfigID config_id, int picture_width,
|
||||||
VASurfaceID *surfaces_ids, int surfaces_count,
|
int picture_height, int flags,
|
||||||
VAContextID *context_id)
|
VASurfaceID *surfaces_ids, int surfaces_count,
|
||||||
|
VAContextID *context_id)
|
||||||
{
|
{
|
||||||
struct cedrus_data *driver_data =
|
struct cedrus_data *driver_data =
|
||||||
(struct cedrus_data *) context->pDriverData;
|
(struct cedrus_data *)context->pDriverData;
|
||||||
struct object_config *config_object;
|
struct object_config *config_object;
|
||||||
struct object_surface *surface_object;
|
struct object_surface *surface_object;
|
||||||
struct object_context *context_object = NULL;
|
struct object_context *context_object = NULL;
|
||||||
@@ -93,13 +94,17 @@ VAStatus SunxiCedrusCreateContext(VADriverContextP context,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = v4l2_set_format(driver_data->video_fd, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, pixelformat, picture_width, picture_height);
|
rc = v4l2_set_format(driver_data->video_fd,
|
||||||
|
V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, pixelformat,
|
||||||
|
picture_width, picture_height);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
status = VA_STATUS_ERROR_OPERATION_FAILED;
|
status = VA_STATUS_ERROR_OPERATION_FAILED;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = v4l2_create_buffers(driver_data->video_fd, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, surfaces_count);
|
rc = v4l2_create_buffers(driver_data->video_fd,
|
||||||
|
V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
|
||||||
|
surfaces_count);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
status = VA_STATUS_ERROR_ALLOCATION_FAILED;
|
status = VA_STATUS_ERROR_ALLOCATION_FAILED;
|
||||||
goto error;
|
goto error;
|
||||||
@@ -125,13 +130,16 @@ VAStatus SunxiCedrusCreateContext(VADriverContextP context,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = v4l2_request_buffer(driver_data->video_fd, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, i, &length, &offset, 1);
|
rc = v4l2_request_buffer(driver_data->video_fd,
|
||||||
|
V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, i,
|
||||||
|
&length, &offset, 1);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
status = VA_STATUS_ERROR_ALLOCATION_FAILED;
|
status = VA_STATUS_ERROR_ALLOCATION_FAILED;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
source_data = mmap(NULL, length, PROT_READ | PROT_WRITE, MAP_SHARED, driver_data->video_fd, offset);
|
source_data = mmap(NULL, length, PROT_READ | PROT_WRITE,
|
||||||
|
MAP_SHARED, driver_data->video_fd, offset);
|
||||||
if (source_data == MAP_FAILED) {
|
if (source_data == MAP_FAILED) {
|
||||||
status = VA_STATUS_ERROR_ALLOCATION_FAILED;
|
status = VA_STATUS_ERROR_ALLOCATION_FAILED;
|
||||||
goto error;
|
goto error;
|
||||||
@@ -143,13 +151,15 @@ VAStatus SunxiCedrusCreateContext(VADriverContextP context,
|
|||||||
surface_object->source_size = length;
|
surface_object->source_size = length;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = v4l2_set_stream(driver_data->video_fd, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, true);
|
rc = v4l2_set_stream(driver_data->video_fd,
|
||||||
|
V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, true);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
status = VA_STATUS_ERROR_OPERATION_FAILED;
|
status = VA_STATUS_ERROR_OPERATION_FAILED;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = v4l2_set_stream(driver_data->video_fd, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, true);
|
rc = v4l2_set_stream(driver_data->video_fd,
|
||||||
|
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, true);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
status = VA_STATUS_ERROR_OPERATION_FAILED;
|
status = VA_STATUS_ERROR_OPERATION_FAILED;
|
||||||
goto error;
|
goto error;
|
||||||
@@ -176,17 +186,18 @@ error:
|
|||||||
free(ids);
|
free(ids);
|
||||||
|
|
||||||
if (context_object != NULL)
|
if (context_object != NULL)
|
||||||
object_heap_free(&driver_data->context_heap, (struct object_base *) context_object);
|
object_heap_free(&driver_data->context_heap,
|
||||||
|
(struct object_base *)context_object);
|
||||||
|
|
||||||
complete:
|
complete:
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusDestroyContext(VADriverContextP context,
|
VAStatus SunxiCedrusDestroyContext(VADriverContextP context,
|
||||||
VAContextID context_id)
|
VAContextID context_id)
|
||||||
{
|
{
|
||||||
struct cedrus_data *driver_data =
|
struct cedrus_data *driver_data =
|
||||||
(struct cedrus_data *) context->pDriverData;
|
(struct cedrus_data *)context->pDriverData;
|
||||||
struct object_context *context_object;
|
struct object_context *context_object;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
@@ -194,13 +205,16 @@ VAStatus SunxiCedrusDestroyContext(VADriverContextP context,
|
|||||||
if (context_object == NULL)
|
if (context_object == NULL)
|
||||||
return VA_STATUS_ERROR_INVALID_CONTEXT;
|
return VA_STATUS_ERROR_INVALID_CONTEXT;
|
||||||
|
|
||||||
object_heap_free(&driver_data->context_heap, (struct object_base *) context_object);
|
object_heap_free(&driver_data->context_heap,
|
||||||
|
(struct object_base *)context_object);
|
||||||
|
|
||||||
rc = v4l2_set_stream(driver_data->video_fd, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, false);
|
rc = v4l2_set_stream(driver_data->video_fd,
|
||||||
|
V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, false);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
return VA_STATUS_ERROR_OPERATION_FAILED;
|
return VA_STATUS_ERROR_OPERATION_FAILED;
|
||||||
|
|
||||||
rc = v4l2_set_stream(driver_data->video_fd, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, false);
|
rc = v4l2_set_stream(driver_data->video_fd,
|
||||||
|
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, false);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
return VA_STATUS_ERROR_OPERATION_FAILED;
|
return VA_STATUS_ERROR_OPERATION_FAILED;
|
||||||
|
|
||||||
|
|||||||
+7
-5
@@ -30,7 +30,8 @@
|
|||||||
|
|
||||||
#include "object_heap.h"
|
#include "object_heap.h"
|
||||||
|
|
||||||
#define CONTEXT(data, id) ((struct object_context *) object_heap_lookup(&(data)->context_heap, id))
|
#define CONTEXT(data, id) \
|
||||||
|
((struct object_context *)object_heap_lookup(&(data)->context_heap, id))
|
||||||
#define CONTEXT_ID_OFFSET 0x02000000
|
#define CONTEXT_ID_OFFSET 0x02000000
|
||||||
|
|
||||||
struct object_context {
|
struct object_context {
|
||||||
@@ -47,10 +48,11 @@ struct object_context {
|
|||||||
};
|
};
|
||||||
|
|
||||||
VAStatus SunxiCedrusCreateContext(VADriverContextP context,
|
VAStatus SunxiCedrusCreateContext(VADriverContextP context,
|
||||||
VAConfigID config_id, int picture_width, int picture_height, int flags,
|
VAConfigID config_id, int picture_width,
|
||||||
VASurfaceID *surfaces_ids, int surfaces_count,
|
int picture_height, int flags,
|
||||||
VAContextID *context_id);
|
VASurfaceID *surfaces_ids, int surfaces_count,
|
||||||
|
VAContextID *context_id);
|
||||||
VAStatus SunxiCedrusDestroyContext(VADriverContextP context,
|
VAStatus SunxiCedrusDestroyContext(VADriverContextP context,
|
||||||
VAContextID context_id);
|
VAContextID context_id);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+28
-31
@@ -27,13 +27,13 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
|
||||||
#include <linux/videodev2.h>
|
#include <linux/videodev2.h>
|
||||||
|
|
||||||
#include "surface.h"
|
|
||||||
#include "sunxi_cedrus.h"
|
#include "sunxi_cedrus.h"
|
||||||
|
#include "surface.h"
|
||||||
#include "v4l2.h"
|
#include "v4l2.h"
|
||||||
|
|
||||||
enum h264_slice_type {
|
enum h264_slice_type {
|
||||||
@@ -42,7 +42,7 @@ enum h264_slice_type {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static int h264_lookup_ref_pic(VAPictureParameterBufferH264 *VAPicture,
|
static int h264_lookup_ref_pic(VAPictureParameterBufferH264 *VAPicture,
|
||||||
unsigned int frame_num)
|
unsigned int frame_num)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -57,10 +57,10 @@ static int h264_lookup_ref_pic(VAPictureParameterBufferH264 *VAPicture,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void h264_va_picture_to_v4l2(struct cedrus_data *driver_data,
|
static void h264_va_picture_to_v4l2(struct cedrus_data *driver_data,
|
||||||
VAPictureParameterBufferH264 *VAPicture,
|
VAPictureParameterBufferH264 *VAPicture,
|
||||||
struct v4l2_ctrl_h264_decode_param *decode,
|
struct v4l2_ctrl_h264_decode_param *decode,
|
||||||
struct v4l2_ctrl_h264_pps *pps,
|
struct v4l2_ctrl_h264_pps *pps,
|
||||||
struct v4l2_ctrl_h264_sps *sps)
|
struct v4l2_ctrl_h264_sps *sps)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -71,8 +71,8 @@ static void h264_va_picture_to_v4l2(struct cedrus_data *driver_data,
|
|||||||
for (i = 0; i < VAPicture->num_ref_frames; i++) {
|
for (i = 0; i < VAPicture->num_ref_frames; i++) {
|
||||||
struct v4l2_h264_dpb_entry *dpb = &decode->dpb[i];
|
struct v4l2_h264_dpb_entry *dpb = &decode->dpb[i];
|
||||||
VAPictureH264 *pic = &VAPicture->ReferenceFrames[i];
|
VAPictureH264 *pic = &VAPicture->ReferenceFrames[i];
|
||||||
struct object_surface *surface_object = SURFACE(driver_data,
|
struct object_surface *surface_object =
|
||||||
pic->picture_id);
|
SURFACE(driver_data, pic->picture_id);
|
||||||
|
|
||||||
if (surface_object)
|
if (surface_object)
|
||||||
dpb->buf_index = surface_object->destination_index;
|
dpb->buf_index = surface_object->destination_index;
|
||||||
@@ -146,8 +146,8 @@ static void h264_va_picture_to_v4l2(struct cedrus_data *driver_data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void h264_va_matrix_to_v4l2(struct cedrus_data *driver_data,
|
static void h264_va_matrix_to_v4l2(struct cedrus_data *driver_data,
|
||||||
VAIQMatrixBufferH264 *VAMatrix,
|
VAIQMatrixBufferH264 *VAMatrix,
|
||||||
struct v4l2_ctrl_h264_scaling_matrix *v4l2_matrix)
|
struct v4l2_ctrl_h264_scaling_matrix *v4l2_matrix)
|
||||||
{
|
{
|
||||||
memcpy(v4l2_matrix->scaling_list_4x4, &VAMatrix->ScalingList4x4,
|
memcpy(v4l2_matrix->scaling_list_4x4, &VAMatrix->ScalingList4x4,
|
||||||
sizeof(VAMatrix->ScalingList4x4));
|
sizeof(VAMatrix->ScalingList4x4));
|
||||||
@@ -164,9 +164,9 @@ static void h264_va_matrix_to_v4l2(struct cedrus_data *driver_data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void h264_va_slice_to_v4l2(struct cedrus_data *driver_data,
|
static void h264_va_slice_to_v4l2(struct cedrus_data *driver_data,
|
||||||
VASliceParameterBufferH264 *VASlice,
|
VASliceParameterBufferH264 *VASlice,
|
||||||
VAPictureParameterBufferH264 *VAPicture,
|
VAPictureParameterBufferH264 *VAPicture,
|
||||||
struct v4l2_ctrl_h264_slice_param *slice)
|
struct v4l2_ctrl_h264_slice_param *slice)
|
||||||
{
|
{
|
||||||
struct v4l2_h264_weight_factors *factors;
|
struct v4l2_h264_weight_factors *factors;
|
||||||
int i;
|
int i;
|
||||||
@@ -188,9 +188,8 @@ static void h264_va_slice_to_v4l2(struct cedrus_data *driver_data,
|
|||||||
VASlice->num_ref_idx_l0_active_minus1;
|
VASlice->num_ref_idx_l0_active_minus1;
|
||||||
|
|
||||||
for (i = 0; i < VASlice->num_ref_idx_l0_active_minus1 + 1; i++)
|
for (i = 0; i < VASlice->num_ref_idx_l0_active_minus1 + 1; i++)
|
||||||
slice->ref_pic_list0[i] =
|
slice->ref_pic_list0[i] = h264_lookup_ref_pic(
|
||||||
h264_lookup_ref_pic(VAPicture,
|
VAPicture, VASlice->RefPicList0[i].frame_idx);
|
||||||
VASlice->RefPicList0[i].frame_idx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((VASlice->slice_type % 5) == H264_SLICE_B) {
|
if ((VASlice->slice_type % 5) == H264_SLICE_B) {
|
||||||
@@ -198,9 +197,8 @@ static void h264_va_slice_to_v4l2(struct cedrus_data *driver_data,
|
|||||||
VASlice->num_ref_idx_l1_active_minus1;
|
VASlice->num_ref_idx_l1_active_minus1;
|
||||||
|
|
||||||
for (i = 0; i < VASlice->num_ref_idx_l1_active_minus1 + 1; i++)
|
for (i = 0; i < VASlice->num_ref_idx_l1_active_minus1 + 1; i++)
|
||||||
slice->ref_pic_list1[i] =
|
slice->ref_pic_list1[i] = h264_lookup_ref_pic(
|
||||||
h264_lookup_ref_pic(VAPicture,
|
VAPicture, VASlice->RefPicList1[i].frame_idx);
|
||||||
VASlice->RefPicList1[i].frame_idx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VASlice->direct_spatial_mv_pred_flag)
|
if (VASlice->direct_spatial_mv_pred_flag)
|
||||||
@@ -244,37 +242,36 @@ int h264_set_controls(struct cedrus_data *driver_data,
|
|||||||
|
|
||||||
h264_va_picture_to_v4l2(driver_data, &surface->params.h264.picture,
|
h264_va_picture_to_v4l2(driver_data, &surface->params.h264.picture,
|
||||||
&decode, &pps, &sps);
|
&decode, &pps, &sps);
|
||||||
h264_va_matrix_to_v4l2(driver_data, &surface->params.h264.matrix, &matrix);
|
h264_va_matrix_to_v4l2(driver_data, &surface->params.h264.matrix,
|
||||||
|
&matrix);
|
||||||
h264_va_slice_to_v4l2(driver_data, &surface->params.h264.slice,
|
h264_va_slice_to_v4l2(driver_data, &surface->params.h264.slice,
|
||||||
&surface->params.h264.picture, &slice);
|
&surface->params.h264.picture, &slice);
|
||||||
|
|
||||||
rc = v4l2_set_control(driver_data->video_fd, surface->request_fd,
|
rc = v4l2_set_control(driver_data->video_fd, surface->request_fd,
|
||||||
V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAMS,
|
V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAMS, &decode,
|
||||||
&decode, sizeof(decode));
|
sizeof(decode));
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
return VA_STATUS_ERROR_OPERATION_FAILED;
|
return VA_STATUS_ERROR_OPERATION_FAILED;
|
||||||
|
|
||||||
rc = v4l2_set_control(driver_data->video_fd, surface->request_fd,
|
rc = v4l2_set_control(driver_data->video_fd, surface->request_fd,
|
||||||
V4L2_CID_MPEG_VIDEO_H264_SLICE_PARAMS,
|
V4L2_CID_MPEG_VIDEO_H264_SLICE_PARAMS, &slice,
|
||||||
&slice, sizeof(slice));
|
sizeof(slice));
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
return VA_STATUS_ERROR_OPERATION_FAILED;
|
return VA_STATUS_ERROR_OPERATION_FAILED;
|
||||||
|
|
||||||
rc = v4l2_set_control(driver_data->video_fd, surface->request_fd,
|
rc = v4l2_set_control(driver_data->video_fd, surface->request_fd,
|
||||||
V4L2_CID_MPEG_VIDEO_H264_PPS,
|
V4L2_CID_MPEG_VIDEO_H264_PPS, &pps, sizeof(pps));
|
||||||
&pps, sizeof(pps));
|
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
return VA_STATUS_ERROR_OPERATION_FAILED;
|
return VA_STATUS_ERROR_OPERATION_FAILED;
|
||||||
|
|
||||||
rc = v4l2_set_control(driver_data->video_fd, surface->request_fd,
|
rc = v4l2_set_control(driver_data->video_fd, surface->request_fd,
|
||||||
V4L2_CID_MPEG_VIDEO_H264_SPS,
|
V4L2_CID_MPEG_VIDEO_H264_SPS, &sps, sizeof(sps));
|
||||||
&sps, sizeof(sps));
|
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
return VA_STATUS_ERROR_OPERATION_FAILED;
|
return VA_STATUS_ERROR_OPERATION_FAILED;
|
||||||
|
|
||||||
rc = v4l2_set_control(driver_data->video_fd, surface->request_fd,
|
rc = v4l2_set_control(driver_data->video_fd, surface->request_fd,
|
||||||
V4L2_CID_MPEG_VIDEO_H264_SCALING_MATRIX,
|
V4L2_CID_MPEG_VIDEO_H264_SCALING_MATRIX, &matrix,
|
||||||
&matrix, sizeof(matrix));
|
sizeof(matrix));
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
return VA_STATUS_ERROR_OPERATION_FAILED;
|
return VA_STATUS_ERROR_OPERATION_FAILED;
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -30,7 +30,6 @@
|
|||||||
struct object_surface;
|
struct object_surface;
|
||||||
struct cedrus_data;
|
struct cedrus_data;
|
||||||
|
|
||||||
int h264_set_controls(struct cedrus_data *data,
|
int h264_set_controls(struct cedrus_data *data, struct object_surface *surface);
|
||||||
struct object_surface *surface);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+38
-23
@@ -23,23 +23,23 @@
|
|||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sunxi_cedrus.h"
|
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
#include "surface.h"
|
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
|
#include "sunxi_cedrus.h"
|
||||||
|
#include "surface.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "v4l2.h"
|
|
||||||
#include "tiled_yuv.h"
|
#include "tiled_yuv.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "v4l2.h"
|
||||||
|
|
||||||
VAStatus SunxiCedrusCreateImage(VADriverContextP context, VAImageFormat *format,
|
VAStatus SunxiCedrusCreateImage(VADriverContextP context, VAImageFormat *format,
|
||||||
int width, int height, VAImage *image)
|
int width, int height, VAImage *image)
|
||||||
{
|
{
|
||||||
struct cedrus_data *driver_data =
|
struct cedrus_data *driver_data =
|
||||||
(struct cedrus_data *) context->pDriverData;
|
(struct cedrus_data *)context->pDriverData;
|
||||||
unsigned int destination_sizes[VIDEO_MAX_PLANES];
|
unsigned int destination_sizes[VIDEO_MAX_PLANES];
|
||||||
unsigned int destination_bytesperlines[VIDEO_MAX_PLANES];
|
unsigned int destination_bytesperlines[VIDEO_MAX_PLANES];
|
||||||
unsigned int destination_planes_count;
|
unsigned int destination_planes_count;
|
||||||
@@ -51,7 +51,10 @@ VAStatus SunxiCedrusCreateImage(VADriverContextP context, VAImageFormat *format,
|
|||||||
unsigned int i;
|
unsigned int i;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = v4l2_get_format(driver_data->video_fd, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, NULL, NULL, destination_bytesperlines, destination_sizes, &destination_planes_count);
|
rc = v4l2_get_format(driver_data->video_fd,
|
||||||
|
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, NULL, NULL,
|
||||||
|
destination_bytesperlines, destination_sizes,
|
||||||
|
&destination_planes_count);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
return VA_STATUS_ERROR_OPERATION_FAILED;
|
return VA_STATUS_ERROR_OPERATION_FAILED;
|
||||||
|
|
||||||
@@ -65,9 +68,11 @@ VAStatus SunxiCedrusCreateImage(VADriverContextP context, VAImageFormat *format,
|
|||||||
if (image_object == NULL)
|
if (image_object == NULL)
|
||||||
return VA_STATUS_ERROR_ALLOCATION_FAILED;
|
return VA_STATUS_ERROR_ALLOCATION_FAILED;
|
||||||
|
|
||||||
status = SunxiCedrusCreateBuffer(context, 0, VAImageBufferType, size, 1, NULL, &buffer_id);
|
status = SunxiCedrusCreateBuffer(context, 0, VAImageBufferType, size, 1,
|
||||||
|
NULL, &buffer_id);
|
||||||
if (status != VA_STATUS_SUCCESS) {
|
if (status != VA_STATUS_SUCCESS) {
|
||||||
object_heap_free(&driver_data->image_heap, (struct object_base *) image_object);
|
object_heap_free(&driver_data->image_heap,
|
||||||
|
(struct object_base *)image_object);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,7 +91,7 @@ VAStatus SunxiCedrusCreateImage(VADriverContextP context, VAImageFormat *format,
|
|||||||
|
|
||||||
for (i = 0; i < image->num_planes; i++) {
|
for (i = 0; i < image->num_planes; i++) {
|
||||||
image->pitches[i] = destination_bytesperlines[i];
|
image->pitches[i] = destination_bytesperlines[i];
|
||||||
image->offsets[i] = i > 0 ? destination_sizes[i-1] : 0;
|
image->offsets[i] = i > 0 ? destination_sizes[i - 1] : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return VA_STATUS_SUCCESS;
|
return VA_STATUS_SUCCESS;
|
||||||
@@ -95,7 +100,7 @@ VAStatus SunxiCedrusCreateImage(VADriverContextP context, VAImageFormat *format,
|
|||||||
VAStatus SunxiCedrusDestroyImage(VADriverContextP context, VAImageID image_id)
|
VAStatus SunxiCedrusDestroyImage(VADriverContextP context, VAImageID image_id)
|
||||||
{
|
{
|
||||||
struct cedrus_data *driver_data =
|
struct cedrus_data *driver_data =
|
||||||
(struct cedrus_data *) context->pDriverData;
|
(struct cedrus_data *)context->pDriverData;
|
||||||
struct object_image *image_object;
|
struct object_image *image_object;
|
||||||
VAStatus status;
|
VAStatus status;
|
||||||
|
|
||||||
@@ -107,16 +112,17 @@ VAStatus SunxiCedrusDestroyImage(VADriverContextP context, VAImageID image_id)
|
|||||||
if (status != VA_STATUS_SUCCESS)
|
if (status != VA_STATUS_SUCCESS)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
object_heap_free(&driver_data->image_heap, (struct object_base *) image_object);
|
object_heap_free(&driver_data->image_heap,
|
||||||
|
(struct object_base *)image_object);
|
||||||
|
|
||||||
return VA_STATUS_SUCCESS;
|
return VA_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusDeriveImage(VADriverContextP context,
|
VAStatus SunxiCedrusDeriveImage(VADriverContextP context,
|
||||||
VASurfaceID surface_id, VAImage *image)
|
VASurfaceID surface_id, VAImage *image)
|
||||||
{
|
{
|
||||||
struct cedrus_data *driver_data =
|
struct cedrus_data *driver_data =
|
||||||
(struct cedrus_data *) context->pDriverData;
|
(struct cedrus_data *)context->pDriverData;
|
||||||
struct object_surface *surface_object;
|
struct object_surface *surface_object;
|
||||||
struct object_buffer *buffer_object;
|
struct object_buffer *buffer_object;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
@@ -137,7 +143,8 @@ VAStatus SunxiCedrusDeriveImage(VADriverContextP context,
|
|||||||
|
|
||||||
format.fourcc = VA_FOURCC_NV12;
|
format.fourcc = VA_FOURCC_NV12;
|
||||||
|
|
||||||
status = SunxiCedrusCreateImage(context, &format, surface_object->width, surface_object->height, image);
|
status = SunxiCedrusCreateImage(context, &format, surface_object->width,
|
||||||
|
surface_object->height, image);
|
||||||
if (status != VA_STATUS_SUCCESS)
|
if (status != VA_STATUS_SUCCESS)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
@@ -147,9 +154,15 @@ VAStatus SunxiCedrusDeriveImage(VADriverContextP context,
|
|||||||
|
|
||||||
for (i = 0; i < surface_object->destination_planes_count; i++) {
|
for (i = 0; i < surface_object->destination_planes_count; i++) {
|
||||||
if (driver_data->tiled_format)
|
if (driver_data->tiled_format)
|
||||||
tiled_to_planar(surface_object->destination_data[i], buffer_object->data + image->offsets[i], image->pitches[i], image->width, i == 0 ? image->height : image->height / 2);
|
tiled_to_planar(surface_object->destination_data[i],
|
||||||
|
buffer_object->data + image->offsets[i],
|
||||||
|
image->pitches[i], image->width,
|
||||||
|
i == 0 ? image->height :
|
||||||
|
image->height / 2);
|
||||||
else
|
else
|
||||||
memcpy(buffer_object->data + image->offsets[i], surface_object->destination_data[i], surface_object->destination_sizes[i]);
|
memcpy(buffer_object->data + image->offsets[i],
|
||||||
|
surface_object->destination_data[i],
|
||||||
|
surface_object->destination_sizes[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
surface_object->status = VASurfaceReady;
|
surface_object->status = VASurfaceReady;
|
||||||
@@ -158,7 +171,8 @@ VAStatus SunxiCedrusDeriveImage(VADriverContextP context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusQueryImageFormats(VADriverContextP context,
|
VAStatus SunxiCedrusQueryImageFormats(VADriverContextP context,
|
||||||
VAImageFormat *formats, int *formats_count)
|
VAImageFormat *formats,
|
||||||
|
int *formats_count)
|
||||||
{
|
{
|
||||||
formats[0].fourcc = VA_FOURCC_NV12;
|
formats[0].fourcc = VA_FOURCC_NV12;
|
||||||
*formats_count = 1;
|
*formats_count = 1;
|
||||||
@@ -167,22 +181,23 @@ VAStatus SunxiCedrusQueryImageFormats(VADriverContextP context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusSetImagePalette(VADriverContextP context,
|
VAStatus SunxiCedrusSetImagePalette(VADriverContextP context,
|
||||||
VAImageID image_id, unsigned char *palette)
|
VAImageID image_id, unsigned char *palette)
|
||||||
{
|
{
|
||||||
return VA_STATUS_SUCCESS;
|
return VA_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusGetImage(VADriverContextP context, VASurfaceID surface_id,
|
VAStatus SunxiCedrusGetImage(VADriverContextP context, VASurfaceID surface_id,
|
||||||
int x, int y, unsigned int width, unsigned int height,
|
int x, int y, unsigned int width,
|
||||||
VAImageID image_id)
|
unsigned int height, VAImageID image_id)
|
||||||
{
|
{
|
||||||
return VA_STATUS_SUCCESS;
|
return VA_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusPutImage(VADriverContextP context, VASurfaceID surface_id,
|
VAStatus SunxiCedrusPutImage(VADriverContextP context, VASurfaceID surface_id,
|
||||||
VAImageID image, int src_x, int src_y, unsigned int src_width,
|
VAImageID image, int src_x, int src_y,
|
||||||
unsigned int src_height, int dst_x, int dst_y, unsigned int dst_width,
|
unsigned int src_width, unsigned int src_height,
|
||||||
unsigned int dst_height)
|
int dst_x, int dst_y, unsigned int dst_width,
|
||||||
|
unsigned int dst_height)
|
||||||
{
|
{
|
||||||
return VA_STATUS_SUCCESS;
|
return VA_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-10
@@ -30,7 +30,9 @@
|
|||||||
|
|
||||||
#include "object_heap.h"
|
#include "object_heap.h"
|
||||||
|
|
||||||
#define IMAGE(id) ((struct object_image *) object_heap_lookup(&driver_data->image_heap, id))
|
#define IMAGE(id) \
|
||||||
|
((struct object_image *)object_heap_lookup(&driver_data->image_heap, \
|
||||||
|
id))
|
||||||
#define IMAGE_ID_OFFSET 0x10000000
|
#define IMAGE_ID_OFFSET 0x10000000
|
||||||
|
|
||||||
struct object_image {
|
struct object_image {
|
||||||
@@ -39,20 +41,22 @@ struct object_image {
|
|||||||
};
|
};
|
||||||
|
|
||||||
VAStatus SunxiCedrusCreateImage(VADriverContextP context, VAImageFormat *format,
|
VAStatus SunxiCedrusCreateImage(VADriverContextP context, VAImageFormat *format,
|
||||||
int width, int height, VAImage *image);
|
int width, int height, VAImage *image);
|
||||||
VAStatus SunxiCedrusDestroyImage(VADriverContextP context, VAImageID image_id);
|
VAStatus SunxiCedrusDestroyImage(VADriverContextP context, VAImageID image_id);
|
||||||
VAStatus SunxiCedrusDeriveImage(VADriverContextP context,
|
VAStatus SunxiCedrusDeriveImage(VADriverContextP context,
|
||||||
VASurfaceID surface_id, VAImage *image);
|
VASurfaceID surface_id, VAImage *image);
|
||||||
VAStatus SunxiCedrusQueryImageFormats(VADriverContextP context,
|
VAStatus SunxiCedrusQueryImageFormats(VADriverContextP context,
|
||||||
VAImageFormat *formats, int *formats_count);
|
VAImageFormat *formats,
|
||||||
|
int *formats_count);
|
||||||
VAStatus SunxiCedrusSetImagePalette(VADriverContextP context,
|
VAStatus SunxiCedrusSetImagePalette(VADriverContextP context,
|
||||||
VAImageID image_id, unsigned char *palette);
|
VAImageID image_id, unsigned char *palette);
|
||||||
VAStatus SunxiCedrusGetImage(VADriverContextP context, VASurfaceID surface_id,
|
VAStatus SunxiCedrusGetImage(VADriverContextP context, VASurfaceID surface_id,
|
||||||
int x, int y, unsigned int width, unsigned int height,
|
int x, int y, unsigned int width,
|
||||||
VAImageID image_id);
|
unsigned int height, VAImageID image_id);
|
||||||
VAStatus SunxiCedrusPutImage(VADriverContextP context, VASurfaceID surface_id,
|
VAStatus SunxiCedrusPutImage(VADriverContextP context, VASurfaceID surface_id,
|
||||||
VAImageID image, int src_x, int src_y, unsigned int src_width,
|
VAImageID image, int src_x, int src_y,
|
||||||
unsigned int src_height, int dst_x, int dst_y, unsigned int dst_width,
|
unsigned int src_width, unsigned int src_height,
|
||||||
unsigned int dst_height);
|
int dst_x, int dst_y, unsigned int dst_width,
|
||||||
|
unsigned int dst_height);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+10
-6
@@ -22,9 +22,9 @@
|
|||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
|
|
||||||
@@ -40,7 +40,8 @@ int media_request_alloc(int media_fd)
|
|||||||
|
|
||||||
rc = ioctl(media_fd, MEDIA_IOC_REQUEST_ALLOC, &request_alloc);
|
rc = ioctl(media_fd, MEDIA_IOC_REQUEST_ALLOC, &request_alloc);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
sunxi_cedrus_log("Unable to allocate media request: %s\n", strerror(errno));
|
sunxi_cedrus_log("Unable to allocate media request: %s\n",
|
||||||
|
strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +54,8 @@ int media_request_reinit(int request_fd)
|
|||||||
|
|
||||||
rc = ioctl(request_fd, MEDIA_REQUEST_IOC_REINIT, NULL);
|
rc = ioctl(request_fd, MEDIA_REQUEST_IOC_REINIT, NULL);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
sunxi_cedrus_log("Unable to reinit media request: %s\n", strerror(errno));
|
sunxi_cedrus_log("Unable to reinit media request: %s\n",
|
||||||
|
strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +68,8 @@ int media_request_queue(int request_fd)
|
|||||||
|
|
||||||
rc = ioctl(request_fd, MEDIA_REQUEST_IOC_QUEUE, NULL);
|
rc = ioctl(request_fd, MEDIA_REQUEST_IOC_QUEUE, NULL);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
sunxi_cedrus_log("Unable to queue media request: %s\n", strerror(errno));
|
sunxi_cedrus_log("Unable to queue media request: %s\n",
|
||||||
|
strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +79,7 @@ int media_request_queue(int request_fd)
|
|||||||
int media_request_wait_completion(int request_fd)
|
int media_request_wait_completion(int request_fd)
|
||||||
{
|
{
|
||||||
struct timeval tv = { 0, 300000 };
|
struct timeval tv = { 0, 300000 };
|
||||||
fd_set except_fds;
|
fd_set except_fds;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
FD_ZERO(&except_fds);
|
FD_ZERO(&except_fds);
|
||||||
@@ -87,7 +90,8 @@ int media_request_wait_completion(int request_fd)
|
|||||||
sunxi_cedrus_log("Timeout when waiting for media request\n");
|
sunxi_cedrus_log("Timeout when waiting for media request\n");
|
||||||
return -1;
|
return -1;
|
||||||
} else if (rc < 0) {
|
} else if (rc < 0) {
|
||||||
sunxi_cedrus_log("Unable to select media request: %s\n", strerror(errno));
|
sunxi_cedrus_log("Unable to select media request: %s\n",
|
||||||
|
strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+37
-19
@@ -23,25 +23,26 @@
|
|||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "mpeg2.h"
|
||||||
#include "context.h"
|
#include "context.h"
|
||||||
#include "sunxi_cedrus.h"
|
#include "sunxi_cedrus.h"
|
||||||
#include "mpeg2.h"
|
|
||||||
#include "surface.h"
|
#include "surface.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
|
||||||
#include <linux/videodev2.h>
|
#include <linux/videodev2.h>
|
||||||
|
|
||||||
#include "v4l2.h"
|
#include "v4l2.h"
|
||||||
|
|
||||||
int mpeg2_set_controls(struct cedrus_data *driver_data,
|
int mpeg2_set_controls(struct cedrus_data *driver_data,
|
||||||
struct object_surface *surface_object)
|
struct object_surface *surface_object)
|
||||||
{
|
{
|
||||||
VAPictureParameterBufferMPEG2 *parameters = &surface_object->params.mpeg2.picture;
|
VAPictureParameterBufferMPEG2 *parameters =
|
||||||
|
&surface_object->params.mpeg2.picture;
|
||||||
struct v4l2_ctrl_mpeg2_slice_params slice_params;
|
struct v4l2_ctrl_mpeg2_slice_params slice_params;
|
||||||
struct object_surface *forward_reference_surface;
|
struct object_surface *forward_reference_surface;
|
||||||
struct object_surface *backward_reference_surface;
|
struct object_surface *backward_reference_surface;
|
||||||
@@ -61,28 +62,45 @@ int mpeg2_set_controls(struct cedrus_data *driver_data,
|
|||||||
slice_params.f_code[1][0] = (parameters->f_code >> 4) & 0x0f;
|
slice_params.f_code[1][0] = (parameters->f_code >> 4) & 0x0f;
|
||||||
slice_params.f_code[1][1] = (parameters->f_code >> 0) & 0x0f;
|
slice_params.f_code[1][1] = (parameters->f_code >> 0) & 0x0f;
|
||||||
|
|
||||||
slice_params.intra_dc_precision = parameters->picture_coding_extension.bits.intra_dc_precision;
|
slice_params.intra_dc_precision =
|
||||||
slice_params.picture_structure = parameters->picture_coding_extension.bits.picture_structure;
|
parameters->picture_coding_extension.bits.intra_dc_precision;
|
||||||
slice_params.top_field_first = parameters->picture_coding_extension.bits.top_field_first;
|
slice_params.picture_structure =
|
||||||
slice_params.frame_pred_frame_dct = parameters->picture_coding_extension.bits.frame_pred_frame_dct;
|
parameters->picture_coding_extension.bits.picture_structure;
|
||||||
slice_params.concealment_motion_vectors = parameters->picture_coding_extension.bits.concealment_motion_vectors;
|
slice_params.top_field_first =
|
||||||
slice_params.q_scale_type = parameters->picture_coding_extension.bits.q_scale_type;
|
parameters->picture_coding_extension.bits.top_field_first;
|
||||||
slice_params.intra_vlc_format = parameters->picture_coding_extension.bits.intra_vlc_format;
|
slice_params.frame_pred_frame_dct =
|
||||||
slice_params.alternate_scan = parameters->picture_coding_extension.bits.alternate_scan;
|
parameters->picture_coding_extension.bits.frame_pred_frame_dct;
|
||||||
|
slice_params.concealment_motion_vectors =
|
||||||
|
parameters->picture_coding_extension.bits
|
||||||
|
.concealment_motion_vectors;
|
||||||
|
slice_params.q_scale_type =
|
||||||
|
parameters->picture_coding_extension.bits.q_scale_type;
|
||||||
|
slice_params.intra_vlc_format =
|
||||||
|
parameters->picture_coding_extension.bits.intra_vlc_format;
|
||||||
|
slice_params.alternate_scan =
|
||||||
|
parameters->picture_coding_extension.bits.alternate_scan;
|
||||||
|
|
||||||
forward_reference_surface = SURFACE(driver_data, parameters->forward_reference_picture);
|
forward_reference_surface =
|
||||||
|
SURFACE(driver_data, parameters->forward_reference_picture);
|
||||||
if (forward_reference_surface != NULL)
|
if (forward_reference_surface != NULL)
|
||||||
slice_params.forward_ref_index = forward_reference_surface->destination_index;
|
slice_params.forward_ref_index =
|
||||||
|
forward_reference_surface->destination_index;
|
||||||
else
|
else
|
||||||
slice_params.forward_ref_index = surface_object->destination_index;
|
slice_params.forward_ref_index =
|
||||||
|
surface_object->destination_index;
|
||||||
|
|
||||||
backward_reference_surface = SURFACE(driver_data, parameters->backward_reference_picture);
|
backward_reference_surface =
|
||||||
|
SURFACE(driver_data, parameters->backward_reference_picture);
|
||||||
if (backward_reference_surface != NULL)
|
if (backward_reference_surface != NULL)
|
||||||
slice_params.backward_ref_index = backward_reference_surface->destination_index;
|
slice_params.backward_ref_index =
|
||||||
|
backward_reference_surface->destination_index;
|
||||||
else
|
else
|
||||||
slice_params.backward_ref_index = surface_object->destination_index;
|
slice_params.backward_ref_index =
|
||||||
|
surface_object->destination_index;
|
||||||
|
|
||||||
rc = v4l2_set_control(driver_data->video_fd, surface_object->request_fd, V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS, &slice_params, sizeof(slice_params));
|
rc = v4l2_set_control(driver_data->video_fd, surface_object->request_fd,
|
||||||
|
V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS,
|
||||||
|
&slice_params, sizeof(slice_params));
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
return VA_STATUS_ERROR_OPERATION_FAILED;
|
return VA_STATUS_ERROR_OPERATION_FAILED;
|
||||||
|
|
||||||
|
|||||||
+20
-9
@@ -39,7 +39,8 @@ static int object_heap_expand(struct object_heap *heap)
|
|||||||
int new_num_buckets = heap->num_buckets + 8;
|
int new_num_buckets = heap->num_buckets + 8;
|
||||||
void **new_bucket;
|
void **new_bucket;
|
||||||
|
|
||||||
new_bucket = realloc(heap->bucket, new_num_buckets * sizeof(void *));
|
new_bucket = realloc(heap->bucket,
|
||||||
|
new_num_buckets * sizeof(void *));
|
||||||
if (new_bucket == NULL)
|
if (new_bucket == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@@ -55,7 +56,9 @@ static int object_heap_expand(struct object_heap *heap)
|
|||||||
next_free = heap->next_free;
|
next_free = heap->next_free;
|
||||||
|
|
||||||
for (i = new_heap_size; i-- > heap->heap_size;) {
|
for (i = new_heap_size; i-- > heap->heap_size;) {
|
||||||
object = (struct object_base *)(new_heap_index + (i - heap->heap_size) * heap->object_size);
|
object = (struct object_base *)(new_heap_index +
|
||||||
|
(i - heap->heap_size) *
|
||||||
|
heap->object_size);
|
||||||
object->id = i + heap->id_offset;
|
object->id = i + heap->id_offset;
|
||||||
object->next_free = next_free;
|
object->next_free = next_free;
|
||||||
next_free = i;
|
next_free = i;
|
||||||
@@ -82,7 +85,8 @@ static int object_heap_allocate_unlocked(struct object_heap *heap)
|
|||||||
bucket_index = heap->next_free / heap->heap_increment;
|
bucket_index = heap->next_free / heap->heap_increment;
|
||||||
object_index = heap->next_free % heap->heap_increment;
|
object_index = heap->next_free % heap->heap_increment;
|
||||||
|
|
||||||
object = (struct object_base *) (heap->bucket[bucket_index] + object_index * heap->object_size);
|
object = (struct object_base *)(heap->bucket[bucket_index] +
|
||||||
|
object_index * heap->object_size);
|
||||||
heap->next_free = object->next_free;
|
heap->next_free = object->next_free;
|
||||||
object->next_free = OBJECT_HEAP_ALLOCATED;
|
object->next_free = OBJECT_HEAP_ALLOCATED;
|
||||||
|
|
||||||
@@ -115,19 +119,22 @@ int object_heap_allocate(struct object_heap *heap)
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct object_base *object_heap_lookup_unlocked(struct object_heap *heap, int id)
|
static struct object_base *object_heap_lookup_unlocked(struct object_heap *heap,
|
||||||
|
int id)
|
||||||
{
|
{
|
||||||
struct object_base *object;
|
struct object_base *object;
|
||||||
int bucket_index, object_index;
|
int bucket_index, object_index;
|
||||||
|
|
||||||
if ((id < heap->id_offset) || (id > (heap->heap_size + heap->id_offset)))
|
if ((id < heap->id_offset) ||
|
||||||
|
(id > (heap->heap_size + heap->id_offset)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
id &= OBJECT_HEAP_ID_MASK;
|
id &= OBJECT_HEAP_ID_MASK;
|
||||||
bucket_index = id / heap->heap_increment;
|
bucket_index = id / heap->heap_increment;
|
||||||
object_index = id % heap->heap_increment;
|
object_index = id % heap->heap_increment;
|
||||||
|
|
||||||
object = (struct object_base *)(heap->bucket[bucket_index] + object_index * heap->object_size);
|
object = (struct object_base *)(heap->bucket[bucket_index] +
|
||||||
|
object_index * heap->object_size);
|
||||||
|
|
||||||
if (object->next_free != OBJECT_HEAP_ALLOCATED)
|
if (object->next_free != OBJECT_HEAP_ALLOCATED)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -153,7 +160,8 @@ struct object_base *object_heap_first(struct object_heap *heap, int *iterator)
|
|||||||
return object_heap_next(heap, iterator);
|
return object_heap_next(heap, iterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct object_base *object_heap_next_unlocked(struct object_heap *heap, int *iterator)
|
static struct object_base *object_heap_next_unlocked(struct object_heap *heap,
|
||||||
|
int *iterator)
|
||||||
{
|
{
|
||||||
struct object_base *object;
|
struct object_base *object;
|
||||||
int bucket_index, object_index;
|
int bucket_index, object_index;
|
||||||
@@ -163,7 +171,9 @@ static struct object_base *object_heap_next_unlocked(struct object_heap *heap, i
|
|||||||
bucket_index = i / heap->heap_increment;
|
bucket_index = i / heap->heap_increment;
|
||||||
object_index = i % heap->heap_increment;
|
object_index = i % heap->heap_increment;
|
||||||
|
|
||||||
object = (struct object_base *)(heap->bucket[bucket_index] + object_index * heap->object_size);
|
object = (struct object_base *)(heap->bucket[bucket_index] +
|
||||||
|
object_index *
|
||||||
|
heap->object_size);
|
||||||
if (object->next_free == OBJECT_HEAP_ALLOCATED) {
|
if (object->next_free == OBJECT_HEAP_ALLOCATED) {
|
||||||
*iterator = i;
|
*iterator = i;
|
||||||
return object;
|
return object;
|
||||||
@@ -188,7 +198,8 @@ struct object_base *object_heap_next(struct object_heap *heap, int *iterator)
|
|||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void object_heap_free_unlocked(struct object_heap *heap, struct object_base *object)
|
static void object_heap_free_unlocked(struct object_heap *heap,
|
||||||
|
struct object_base *object)
|
||||||
{
|
{
|
||||||
object->next_free = heap->next_free;
|
object->next_free = heap->next_free;
|
||||||
heap->next_free = object->id & OBJECT_HEAP_ID_MASK;
|
heap->next_free = object->id & OBJECT_HEAP_ID_MASK;
|
||||||
|
|||||||
@@ -41,7 +41,6 @@
|
|||||||
* Structures
|
* Structures
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
struct object_base {
|
struct object_base {
|
||||||
int id;
|
int id;
|
||||||
int next_free;
|
int next_free;
|
||||||
|
|||||||
+53
-28
@@ -23,15 +23,15 @@
|
|||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sunxi_cedrus.h"
|
|
||||||
#include "picture.h"
|
#include "picture.h"
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
#include "context.h"
|
|
||||||
#include "surface.h"
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "context.h"
|
||||||
|
#include "sunxi_cedrus.h"
|
||||||
|
#include "surface.h"
|
||||||
|
|
||||||
#include "mpeg2.h"
|
|
||||||
#include "h264.h"
|
#include "h264.h"
|
||||||
|
#include "mpeg2.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -42,13 +42,14 @@
|
|||||||
|
|
||||||
#include <linux/videodev2.h>
|
#include <linux/videodev2.h>
|
||||||
|
|
||||||
#include "v4l2.h"
|
|
||||||
#include "media.h"
|
#include "media.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "v4l2.h"
|
||||||
|
|
||||||
static VAStatus codec_store_buffer(struct cedrus_data *driver_data,
|
static VAStatus codec_store_buffer(struct cedrus_data *driver_data,
|
||||||
VAProfile profile, struct object_surface *surface_object,
|
VAProfile profile,
|
||||||
struct object_buffer *buffer_object)
|
struct object_surface *surface_object,
|
||||||
|
struct object_buffer *buffer_object)
|
||||||
{
|
{
|
||||||
switch (buffer_object->type) {
|
switch (buffer_object->type) {
|
||||||
case VASliceDataBufferType:
|
case VASliceDataBufferType:
|
||||||
@@ -58,22 +59,30 @@ static VAStatus codec_store_buffer(struct cedrus_data *driver_data,
|
|||||||
* RenderPicture), we can't use a V4L2 buffer directly
|
* RenderPicture), we can't use a V4L2 buffer directly
|
||||||
* and have to copy from a regular buffer.
|
* and have to copy from a regular buffer.
|
||||||
*/
|
*/
|
||||||
memcpy(surface_object->source_data + surface_object->slices_size, buffer_object->data, buffer_object->size * buffer_object->count);
|
memcpy(surface_object->source_data +
|
||||||
surface_object->slices_size += buffer_object->size * buffer_object->count;
|
surface_object->slices_size,
|
||||||
|
buffer_object->data,
|
||||||
|
buffer_object->size * buffer_object->count);
|
||||||
|
surface_object->slices_size +=
|
||||||
|
buffer_object->size * buffer_object->count;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VAPictureParameterBufferType:
|
case VAPictureParameterBufferType:
|
||||||
switch (profile) {
|
switch (profile) {
|
||||||
case VAProfileMPEG2Simple:
|
case VAProfileMPEG2Simple:
|
||||||
case VAProfileMPEG2Main:
|
case VAProfileMPEG2Main:
|
||||||
memcpy(&surface_object->params.mpeg2.picture, buffer_object->data, sizeof(surface_object->params.mpeg2.picture));
|
memcpy(&surface_object->params.mpeg2.picture,
|
||||||
|
buffer_object->data,
|
||||||
|
sizeof(surface_object->params.mpeg2.picture));
|
||||||
break;
|
break;
|
||||||
case VAProfileH264Main:
|
case VAProfileH264Main:
|
||||||
case VAProfileH264High:
|
case VAProfileH264High:
|
||||||
case VAProfileH264ConstrainedBaseline:
|
case VAProfileH264ConstrainedBaseline:
|
||||||
case VAProfileH264MultiviewHigh:
|
case VAProfileH264MultiviewHigh:
|
||||||
case VAProfileH264StereoHigh:
|
case VAProfileH264StereoHigh:
|
||||||
memcpy(&surface_object->params.h264.picture, buffer_object->data, sizeof(surface_object->params.h264.picture));
|
memcpy(&surface_object->params.h264.picture,
|
||||||
|
buffer_object->data,
|
||||||
|
sizeof(surface_object->params.h264.picture));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -87,7 +96,9 @@ static VAStatus codec_store_buffer(struct cedrus_data *driver_data,
|
|||||||
case VAProfileH264ConstrainedBaseline:
|
case VAProfileH264ConstrainedBaseline:
|
||||||
case VAProfileH264MultiviewHigh:
|
case VAProfileH264MultiviewHigh:
|
||||||
case VAProfileH264StereoHigh:
|
case VAProfileH264StereoHigh:
|
||||||
memcpy(&surface_object->params.h264.slice, buffer_object->data, sizeof(surface_object->params.h264.slice));
|
memcpy(&surface_object->params.h264.slice,
|
||||||
|
buffer_object->data,
|
||||||
|
sizeof(surface_object->params.h264.slice));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -102,7 +113,9 @@ static VAStatus codec_store_buffer(struct cedrus_data *driver_data,
|
|||||||
case VAProfileH264ConstrainedBaseline:
|
case VAProfileH264ConstrainedBaseline:
|
||||||
case VAProfileH264MultiviewHigh:
|
case VAProfileH264MultiviewHigh:
|
||||||
case VAProfileH264StereoHigh:
|
case VAProfileH264StereoHigh:
|
||||||
memcpy(&surface_object->params.h264.matrix, buffer_object->data, sizeof(surface_object->params.h264.matrix));
|
memcpy(&surface_object->params.h264.matrix,
|
||||||
|
buffer_object->data,
|
||||||
|
sizeof(surface_object->params.h264.matrix));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -118,7 +131,8 @@ static VAStatus codec_store_buffer(struct cedrus_data *driver_data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static VAStatus codec_set_controls(struct cedrus_data *driver_data,
|
static VAStatus codec_set_controls(struct cedrus_data *driver_data,
|
||||||
VAProfile profile, struct object_surface *surface_object)
|
VAProfile profile,
|
||||||
|
struct object_surface *surface_object)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
@@ -148,10 +162,10 @@ static VAStatus codec_set_controls(struct cedrus_data *driver_data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusBeginPicture(VADriverContextP context,
|
VAStatus SunxiCedrusBeginPicture(VADriverContextP context,
|
||||||
VAContextID context_id, VASurfaceID surface_id)
|
VAContextID context_id, VASurfaceID surface_id)
|
||||||
{
|
{
|
||||||
struct cedrus_data *driver_data =
|
struct cedrus_data *driver_data =
|
||||||
(struct cedrus_data *) context->pDriverData;
|
(struct cedrus_data *)context->pDriverData;
|
||||||
struct object_context *context_object;
|
struct object_context *context_object;
|
||||||
struct object_surface *surface_object;
|
struct object_surface *surface_object;
|
||||||
|
|
||||||
@@ -173,10 +187,11 @@ VAStatus SunxiCedrusBeginPicture(VADriverContextP context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusRenderPicture(VADriverContextP context,
|
VAStatus SunxiCedrusRenderPicture(VADriverContextP context,
|
||||||
VAContextID context_id, VABufferID *buffers_ids, int buffers_count)
|
VAContextID context_id,
|
||||||
|
VABufferID *buffers_ids, int buffers_count)
|
||||||
{
|
{
|
||||||
struct cedrus_data *driver_data =
|
struct cedrus_data *driver_data =
|
||||||
(struct cedrus_data *) context->pDriverData;
|
(struct cedrus_data *)context->pDriverData;
|
||||||
struct object_context *context_object;
|
struct object_context *context_object;
|
||||||
struct object_config *config_object;
|
struct object_config *config_object;
|
||||||
struct object_surface *surface_object;
|
struct object_surface *surface_object;
|
||||||
@@ -192,7 +207,8 @@ VAStatus SunxiCedrusRenderPicture(VADriverContextP context,
|
|||||||
if (config_object == NULL)
|
if (config_object == NULL)
|
||||||
return VA_STATUS_ERROR_INVALID_CONFIG;
|
return VA_STATUS_ERROR_INVALID_CONFIG;
|
||||||
|
|
||||||
surface_object = SURFACE(driver_data, context_object->render_surface_id);
|
surface_object =
|
||||||
|
SURFACE(driver_data, context_object->render_surface_id);
|
||||||
if (surface_object == NULL)
|
if (surface_object == NULL)
|
||||||
return VA_STATUS_ERROR_INVALID_SURFACE;
|
return VA_STATUS_ERROR_INVALID_SURFACE;
|
||||||
|
|
||||||
@@ -201,7 +217,8 @@ VAStatus SunxiCedrusRenderPicture(VADriverContextP context,
|
|||||||
if (buffer_object == NULL)
|
if (buffer_object == NULL)
|
||||||
return VA_STATUS_ERROR_INVALID_BUFFER;
|
return VA_STATUS_ERROR_INVALID_BUFFER;
|
||||||
|
|
||||||
rc = codec_store_buffer(driver_data, config_object->profile, surface_object, buffer_object);
|
rc = codec_store_buffer(driver_data, config_object->profile,
|
||||||
|
surface_object, buffer_object);
|
||||||
if (rc != VA_STATUS_SUCCESS)
|
if (rc != VA_STATUS_SUCCESS)
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@@ -209,11 +226,10 @@ VAStatus SunxiCedrusRenderPicture(VADriverContextP context,
|
|||||||
return VA_STATUS_SUCCESS;
|
return VA_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusEndPicture(VADriverContextP context,
|
VAStatus SunxiCedrusEndPicture(VADriverContextP context, VAContextID context_id)
|
||||||
VAContextID context_id)
|
|
||||||
{
|
{
|
||||||
struct cedrus_data *driver_data =
|
struct cedrus_data *driver_data =
|
||||||
(struct cedrus_data *) context->pDriverData;
|
(struct cedrus_data *)context->pDriverData;
|
||||||
struct object_context *context_object;
|
struct object_context *context_object;
|
||||||
struct object_config *config_object;
|
struct object_config *config_object;
|
||||||
struct object_surface *surface_object;
|
struct object_surface *surface_object;
|
||||||
@@ -229,7 +245,8 @@ VAStatus SunxiCedrusEndPicture(VADriverContextP context,
|
|||||||
if (config_object == NULL)
|
if (config_object == NULL)
|
||||||
return VA_STATUS_ERROR_INVALID_CONFIG;
|
return VA_STATUS_ERROR_INVALID_CONFIG;
|
||||||
|
|
||||||
surface_object = SURFACE(driver_data, context_object->render_surface_id);
|
surface_object =
|
||||||
|
SURFACE(driver_data, context_object->render_surface_id);
|
||||||
if (surface_object == NULL)
|
if (surface_object == NULL)
|
||||||
return VA_STATUS_ERROR_INVALID_SURFACE;
|
return VA_STATUS_ERROR_INVALID_SURFACE;
|
||||||
|
|
||||||
@@ -242,21 +259,29 @@ VAStatus SunxiCedrusEndPicture(VADriverContextP context,
|
|||||||
surface_object->request_fd = request_fd;
|
surface_object->request_fd = request_fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = codec_set_controls(driver_data, config_object->profile, surface_object);
|
rc = codec_set_controls(driver_data, config_object->profile,
|
||||||
|
surface_object);
|
||||||
if (rc != VA_STATUS_SUCCESS)
|
if (rc != VA_STATUS_SUCCESS)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
rc = v4l2_queue_buffer(driver_data->video_fd, -1, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, surface_object->destination_index, 0, surface_object->destination_buffers_count);
|
rc = v4l2_queue_buffer(driver_data->video_fd, -1,
|
||||||
|
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
|
||||||
|
surface_object->destination_index, 0,
|
||||||
|
surface_object->destination_buffers_count);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
return VA_STATUS_ERROR_OPERATION_FAILED;
|
return VA_STATUS_ERROR_OPERATION_FAILED;
|
||||||
|
|
||||||
rc = v4l2_queue_buffer(driver_data->video_fd, request_fd, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, surface_object->source_index, surface_object->slices_size, 1);
|
rc = v4l2_queue_buffer(driver_data->video_fd, request_fd,
|
||||||
|
V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
|
||||||
|
surface_object->source_index,
|
||||||
|
surface_object->slices_size, 1);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
return VA_STATUS_ERROR_OPERATION_FAILED;
|
return VA_STATUS_ERROR_OPERATION_FAILED;
|
||||||
|
|
||||||
surface_object->slices_size = 0;
|
surface_object->slices_size = 0;
|
||||||
|
|
||||||
status = SunxiCedrusSyncSurface(context, context_object->render_surface_id);
|
status = SunxiCedrusSyncSurface(context,
|
||||||
|
context_object->render_surface_id);
|
||||||
if (status != VA_STATUS_SUCCESS)
|
if (status != VA_STATUS_SUCCESS)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
|
|||||||
+5
-3
@@ -31,10 +31,12 @@
|
|||||||
#include "object_heap.h"
|
#include "object_heap.h"
|
||||||
|
|
||||||
VAStatus SunxiCedrusBeginPicture(VADriverContextP context,
|
VAStatus SunxiCedrusBeginPicture(VADriverContextP context,
|
||||||
VAContextID context_id, VASurfaceID surface_id);
|
VAContextID context_id,
|
||||||
|
VASurfaceID surface_id);
|
||||||
VAStatus SunxiCedrusRenderPicture(VADriverContextP context,
|
VAStatus SunxiCedrusRenderPicture(VADriverContextP context,
|
||||||
VAContextID context_id, VABufferID *buffers, int buffers_count);
|
VAContextID context_id, VABufferID *buffers,
|
||||||
|
int buffers_count);
|
||||||
VAStatus SunxiCedrusEndPicture(VADriverContextP context,
|
VAStatus SunxiCedrusEndPicture(VADriverContextP context,
|
||||||
VAContextID context_id);
|
VAContextID context_id);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+30
-16
@@ -23,65 +23,79 @@
|
|||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sunxi_cedrus.h"
|
|
||||||
#include "subpicture.h"
|
#include "subpicture.h"
|
||||||
|
#include "sunxi_cedrus.h"
|
||||||
|
|
||||||
VAStatus SunxiCedrusCreateSubpicture(VADriverContextP context,
|
VAStatus SunxiCedrusCreateSubpicture(VADriverContextP context,
|
||||||
VAImageID image_id, VASubpictureID *subpicture_id)
|
VAImageID image_id,
|
||||||
|
VASubpictureID *subpicture_id)
|
||||||
{
|
{
|
||||||
return VA_STATUS_SUCCESS;
|
return VA_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusDestroySubpicture(VADriverContextP context,
|
VAStatus SunxiCedrusDestroySubpicture(VADriverContextP context,
|
||||||
VASubpictureID subpicture_id)
|
VASubpictureID subpicture_id)
|
||||||
{
|
{
|
||||||
return VA_STATUS_SUCCESS;
|
return VA_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusQuerySubpictureFormats(VADriverContextP context,
|
VAStatus SunxiCedrusQuerySubpictureFormats(VADriverContextP context,
|
||||||
VAImageFormat *formats, unsigned int *flags,
|
VAImageFormat *formats,
|
||||||
unsigned int *formats_count)
|
unsigned int *flags,
|
||||||
|
unsigned int *formats_count)
|
||||||
{
|
{
|
||||||
return VA_STATUS_SUCCESS;
|
return VA_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusSetSubpictureImage(VADriverContextP context,
|
VAStatus SunxiCedrusSetSubpictureImage(VADriverContextP context,
|
||||||
VASubpictureID subpicture_id, VAImageID image_id)
|
VASubpictureID subpicture_id,
|
||||||
|
VAImageID image_id)
|
||||||
{
|
{
|
||||||
return VA_STATUS_SUCCESS;
|
return VA_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusSetSubpicturePalette(VADriverContextP context,
|
VAStatus SunxiCedrusSetSubpicturePalette(VADriverContextP context,
|
||||||
VASubpictureID subpicture_id, unsigned char *palette)
|
VASubpictureID subpicture_id,
|
||||||
|
unsigned char *palette)
|
||||||
{
|
{
|
||||||
return VA_STATUS_SUCCESS;
|
return VA_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusSetSubpictureChromakey(VADriverContextP context,
|
VAStatus SunxiCedrusSetSubpictureChromakey(VADriverContextP context,
|
||||||
VASubpictureID subpicture_id, unsigned int chromakey_min,
|
VASubpictureID subpicture_id,
|
||||||
unsigned int chromakey_max, unsigned int chromakey_mask)
|
unsigned int chromakey_min,
|
||||||
|
unsigned int chromakey_max,
|
||||||
|
unsigned int chromakey_mask)
|
||||||
{
|
{
|
||||||
return VA_STATUS_SUCCESS;
|
return VA_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusSetSubpictureGlobalAlpha(VADriverContextP context,
|
VAStatus SunxiCedrusSetSubpictureGlobalAlpha(VADriverContextP context,
|
||||||
VASubpictureID subpicture_id, float global_alpha)
|
VASubpictureID subpicture_id,
|
||||||
|
float global_alpha)
|
||||||
{
|
{
|
||||||
return VA_STATUS_SUCCESS;
|
return VA_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusAssociateSubpicture(VADriverContextP context,
|
VAStatus SunxiCedrusAssociateSubpicture(VADriverContextP context,
|
||||||
VASubpictureID subpicture_id, VASurfaceID *surfaces_ids,
|
VASubpictureID subpicture_id,
|
||||||
int surfaces_count, short src_x, short src_y, unsigned short src_width,
|
VASurfaceID *surfaces_ids,
|
||||||
unsigned short src_height, short dst_x, short dst_y,
|
int surfaces_count,
|
||||||
unsigned short dst_width, unsigned short dst_height, unsigned int flags)
|
short src_x, short src_y,
|
||||||
|
unsigned short src_width,
|
||||||
|
unsigned short src_height,
|
||||||
|
short dst_x, short dst_y,
|
||||||
|
unsigned short dst_width,
|
||||||
|
unsigned short dst_height,
|
||||||
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
return VA_STATUS_SUCCESS;
|
return VA_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusDeassociateSubpicture(VADriverContextP context,
|
VAStatus SunxiCedrusDeassociateSubpicture(VADriverContextP context,
|
||||||
VASubpictureID subpicture_id, VASurfaceID *surfaces_ids,
|
VASubpictureID subpicture_id,
|
||||||
int surfaces_count)
|
VASurfaceID *surfaces_ids,
|
||||||
|
int surfaces_count)
|
||||||
{
|
{
|
||||||
return VA_STATUS_SUCCESS;
|
return VA_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
+29
-16
@@ -29,29 +29,42 @@
|
|||||||
#include <va/va_backend.h>
|
#include <va/va_backend.h>
|
||||||
|
|
||||||
VAStatus SunxiCedrusCreateSubpicture(VADriverContextP context,
|
VAStatus SunxiCedrusCreateSubpicture(VADriverContextP context,
|
||||||
VAImageID image_id, VASubpictureID *subpicture_id);
|
VAImageID image_id,
|
||||||
|
VASubpictureID *subpicture_id);
|
||||||
VAStatus SunxiCedrusDestroySubpicture(VADriverContextP context,
|
VAStatus SunxiCedrusDestroySubpicture(VADriverContextP context,
|
||||||
VASubpictureID subpicture_id);
|
VASubpictureID subpicture_id);
|
||||||
VAStatus SunxiCedrusQuerySubpictureFormats(VADriverContextP context,
|
VAStatus SunxiCedrusQuerySubpictureFormats(VADriverContextP context,
|
||||||
VAImageFormat *formats, unsigned int *flags,
|
VAImageFormat *formats,
|
||||||
unsigned int *formats_count);
|
unsigned int *flags,
|
||||||
|
unsigned int *formats_count);
|
||||||
VAStatus SunxiCedrusSetSubpictureImage(VADriverContextP context,
|
VAStatus SunxiCedrusSetSubpictureImage(VADriverContextP context,
|
||||||
VASubpictureID subpicture_id, VAImageID image_id);
|
VASubpictureID subpicture_id,
|
||||||
|
VAImageID image_id);
|
||||||
VAStatus SunxiCedrusSetSubpicturePalette(VADriverContextP context,
|
VAStatus SunxiCedrusSetSubpicturePalette(VADriverContextP context,
|
||||||
VASubpictureID subpicture_id, unsigned char *palette);
|
VASubpictureID subpicture_id,
|
||||||
|
unsigned char *palette);
|
||||||
VAStatus SunxiCedrusSetSubpictureChromakey(VADriverContextP context,
|
VAStatus SunxiCedrusSetSubpictureChromakey(VADriverContextP context,
|
||||||
VASubpictureID subpicture_id, unsigned int chromakey_min,
|
VASubpictureID subpicture_id,
|
||||||
unsigned int chromakey_max, unsigned int chromakey_mask);
|
unsigned int chromakey_min,
|
||||||
|
unsigned int chromakey_max,
|
||||||
|
unsigned int chromakey_mask);
|
||||||
VAStatus SunxiCedrusSetSubpictureGlobalAlpha(VADriverContextP context,
|
VAStatus SunxiCedrusSetSubpictureGlobalAlpha(VADriverContextP context,
|
||||||
VASubpictureID subpicture_id, float global_alpha);
|
VASubpictureID subpicture_id,
|
||||||
|
float global_alpha);
|
||||||
VAStatus SunxiCedrusAssociateSubpicture(VADriverContextP context,
|
VAStatus SunxiCedrusAssociateSubpicture(VADriverContextP context,
|
||||||
VASubpictureID subpicture_id, VASurfaceID *surfaces_ids,
|
VASubpictureID subpicture_id,
|
||||||
int surfaces_count, short src_x, short src_y, unsigned short src_width,
|
VASurfaceID *surfaces_ids,
|
||||||
unsigned short src_height, short dst_x, short dst_y,
|
int surfaces_count,
|
||||||
unsigned short dst_width, unsigned short dst_height,
|
short src_x, short src_y,
|
||||||
unsigned int flags);
|
unsigned short src_width,
|
||||||
|
unsigned short src_height,
|
||||||
|
short dst_x, short dst_y,
|
||||||
|
unsigned short dst_width,
|
||||||
|
unsigned short dst_height,
|
||||||
|
unsigned int flags);
|
||||||
VAStatus SunxiCedrusDeassociateSubpicture(VADriverContextP context,
|
VAStatus SunxiCedrusDeassociateSubpicture(VADriverContextP context,
|
||||||
VASubpictureID subpicture_id, VASurfaceID *surfaces_ids,
|
VASubpictureID subpicture_id,
|
||||||
int surfaces_count);
|
VASurfaceID *surfaces_ids,
|
||||||
|
int surfaces_count);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+52
-29
@@ -24,12 +24,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
|
#include "config.h"
|
||||||
#include "context.h"
|
#include "context.h"
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
#include "picture.h"
|
#include "picture.h"
|
||||||
#include "subpicture.h"
|
#include "subpicture.h"
|
||||||
#include "surface.h"
|
#include "surface.h"
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#include "autoconfig.h"
|
#include "autoconfig.h"
|
||||||
|
|
||||||
@@ -39,13 +39,13 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdarg.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
|
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
|
|
||||||
/* Set default visibility for the init function only. */
|
/* Set default visibility for the init function only. */
|
||||||
VAStatus __attribute__((visibility("default")))
|
VAStatus __attribute__((visibility("default")))
|
||||||
VA_DRIVER_INIT_FUNC(VADriverContextP context);
|
VA_DRIVER_INIT_FUNC(VADriverContextP context);
|
||||||
|
|
||||||
VAStatus VA_DRIVER_INIT_FUNC(VADriverContextP context)
|
VAStatus VA_DRIVER_INIT_FUNC(VADriverContextP context)
|
||||||
{
|
{
|
||||||
@@ -112,7 +112,8 @@ VAStatus VA_DRIVER_INIT_FUNC(VADriverContextP context)
|
|||||||
vtable->vaDestroySubpicture = SunxiCedrusDestroySubpicture;
|
vtable->vaDestroySubpicture = SunxiCedrusDestroySubpicture;
|
||||||
vtable->vaSetSubpictureImage = SunxiCedrusSetSubpictureImage;
|
vtable->vaSetSubpictureImage = SunxiCedrusSetSubpictureImage;
|
||||||
vtable->vaSetSubpictureChromakey = SunxiCedrusSetSubpictureChromakey;
|
vtable->vaSetSubpictureChromakey = SunxiCedrusSetSubpictureChromakey;
|
||||||
vtable->vaSetSubpictureGlobalAlpha = SunxiCedrusSetSubpictureGlobalAlpha;
|
vtable->vaSetSubpictureGlobalAlpha =
|
||||||
|
SunxiCedrusSetSubpictureGlobalAlpha;
|
||||||
vtable->vaAssociateSubpicture = SunxiCedrusAssociateSubpicture;
|
vtable->vaAssociateSubpicture = SunxiCedrusAssociateSubpicture;
|
||||||
vtable->vaDeassociateSubpicture = SunxiCedrusDeassociateSubpicture;
|
vtable->vaDeassociateSubpicture = SunxiCedrusDeassociateSubpicture;
|
||||||
vtable->vaQueryDisplayAttributes = SunxiCedrusQueryDisplayAttributes;
|
vtable->vaQueryDisplayAttributes = SunxiCedrusQueryDisplayAttributes;
|
||||||
@@ -125,13 +126,18 @@ VAStatus VA_DRIVER_INIT_FUNC(VADriverContextP context)
|
|||||||
driver_data = malloc(sizeof(*driver_data));
|
driver_data = malloc(sizeof(*driver_data));
|
||||||
memset(driver_data, 0, sizeof(*driver_data));
|
memset(driver_data, 0, sizeof(*driver_data));
|
||||||
|
|
||||||
context->pDriverData = (void *) driver_data;
|
context->pDriverData = (void *)driver_data;
|
||||||
|
|
||||||
object_heap_init(&driver_data->config_heap, sizeof(struct object_config), CONFIG_ID_OFFSET);
|
object_heap_init(&driver_data->config_heap,
|
||||||
object_heap_init(&driver_data->context_heap, sizeof(struct object_context), CONTEXT_ID_OFFSET);
|
sizeof(struct object_config), CONFIG_ID_OFFSET);
|
||||||
object_heap_init(&driver_data->surface_heap, sizeof(struct object_surface), SURFACE_ID_OFFSET);
|
object_heap_init(&driver_data->context_heap,
|
||||||
object_heap_init(&driver_data->buffer_heap, sizeof(struct object_buffer), BUFFER_ID_OFFSET);
|
sizeof(struct object_context), CONTEXT_ID_OFFSET);
|
||||||
object_heap_init(&driver_data->image_heap, sizeof(struct object_image), IMAGE_ID_OFFSET);
|
object_heap_init(&driver_data->surface_heap,
|
||||||
|
sizeof(struct object_surface), SURFACE_ID_OFFSET);
|
||||||
|
object_heap_init(&driver_data->buffer_heap,
|
||||||
|
sizeof(struct object_buffer), BUFFER_ID_OFFSET);
|
||||||
|
object_heap_init(&driver_data->image_heap, sizeof(struct object_image),
|
||||||
|
IMAGE_ID_OFFSET);
|
||||||
|
|
||||||
video_path = getenv("LIBVA_CEDRUS_VIDEO_PATH");
|
video_path = getenv("LIBVA_CEDRUS_VIDEO_PATH");
|
||||||
if (video_path == NULL)
|
if (video_path == NULL)
|
||||||
@@ -143,7 +149,8 @@ VAStatus VA_DRIVER_INIT_FUNC(VADriverContextP context)
|
|||||||
|
|
||||||
rc = ioctl(video_fd, VIDIOC_QUERYCAP, &capability);
|
rc = ioctl(video_fd, VIDIOC_QUERYCAP, &capability);
|
||||||
if (rc < 0 || !(capability.capabilities & V4L2_CAP_VIDEO_M2M_MPLANE)) {
|
if (rc < 0 || !(capability.capabilities & V4L2_CAP_VIDEO_M2M_MPLANE)) {
|
||||||
sunxi_cedrus_log("Video device %s does not support m2m mplanes\n", video_path);
|
sunxi_cedrus_log("Video device %s does not support m2m mplanes\n",
|
||||||
|
video_path);
|
||||||
status = VA_STATUS_ERROR_OPERATION_FAILED;
|
status = VA_STATUS_ERROR_OPERATION_FAILED;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@@ -178,7 +185,7 @@ complete:
|
|||||||
VAStatus SunxiCedrusTerminate(VADriverContextP context)
|
VAStatus SunxiCedrusTerminate(VADriverContextP context)
|
||||||
{
|
{
|
||||||
struct cedrus_data *driver_data =
|
struct cedrus_data *driver_data =
|
||||||
(struct cedrus_data *) context->pDriverData;
|
(struct cedrus_data *)context->pDriverData;
|
||||||
struct object_buffer *buffer_object;
|
struct object_buffer *buffer_object;
|
||||||
struct object_image *image_object;
|
struct object_image *image_object;
|
||||||
struct object_surface *surface_object;
|
struct object_surface *surface_object;
|
||||||
@@ -191,42 +198,58 @@ VAStatus SunxiCedrusTerminate(VADriverContextP context)
|
|||||||
|
|
||||||
/* Cleanup leftover buffers. */
|
/* Cleanup leftover buffers. */
|
||||||
|
|
||||||
image_object = (struct object_image *) object_heap_first(&driver_data->image_heap, &iterator);
|
image_object = (struct object_image *)
|
||||||
|
object_heap_first(&driver_data->image_heap, &iterator);
|
||||||
while (image_object != NULL) {
|
while (image_object != NULL) {
|
||||||
SunxiCedrusDestroyImage(context, (VAImageID) image_object->base.id);
|
SunxiCedrusDestroyImage(context,
|
||||||
image_object = (struct object_image *) object_heap_next(&driver_data->image_heap, &iterator);
|
(VAImageID)image_object->base.id);
|
||||||
|
image_object = (struct object_image *)
|
||||||
|
object_heap_next(&driver_data->image_heap, &iterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
object_heap_destroy(&driver_data->image_heap);
|
object_heap_destroy(&driver_data->image_heap);
|
||||||
|
|
||||||
buffer_object = (struct object_buffer *) object_heap_first(&driver_data->buffer_heap, &iterator);
|
buffer_object = (struct object_buffer *)
|
||||||
|
object_heap_first(&driver_data->buffer_heap, &iterator);
|
||||||
while (buffer_object != NULL) {
|
while (buffer_object != NULL) {
|
||||||
SunxiCedrusDestroyBuffer(context, (VABufferID) buffer_object->base.id);
|
SunxiCedrusDestroyBuffer(context,
|
||||||
buffer_object = (struct object_buffer *) object_heap_next(&driver_data->buffer_heap, &iterator);
|
(VABufferID)buffer_object->base.id);
|
||||||
|
buffer_object = (struct object_buffer *)
|
||||||
|
object_heap_next(&driver_data->buffer_heap, &iterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
object_heap_destroy(&driver_data->buffer_heap);
|
object_heap_destroy(&driver_data->buffer_heap);
|
||||||
|
|
||||||
surface_object = (struct object_surface *) object_heap_first(&driver_data->surface_heap, &iterator);
|
surface_object = (struct object_surface *)
|
||||||
|
object_heap_first(&driver_data->surface_heap, &iterator);
|
||||||
while (surface_object != NULL) {
|
while (surface_object != NULL) {
|
||||||
SunxiCedrusDestroySurfaces(context, (VASurfaceID *) &surface_object->base.id, 1);
|
SunxiCedrusDestroySurfaces(context,
|
||||||
surface_object = (struct object_surface *) object_heap_next(&driver_data->surface_heap, &iterator);
|
(VASurfaceID *)&surface_object->base.id,
|
||||||
|
1);
|
||||||
|
surface_object = (struct object_surface *)
|
||||||
|
object_heap_next(&driver_data->surface_heap, &iterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
object_heap_destroy(&driver_data->surface_heap);
|
object_heap_destroy(&driver_data->surface_heap);
|
||||||
|
|
||||||
context_object = (struct object_context *) object_heap_first(&driver_data->context_heap, &iterator);
|
context_object = (struct object_context *)
|
||||||
|
object_heap_first(&driver_data->context_heap, &iterator);
|
||||||
while (context_object != NULL) {
|
while (context_object != NULL) {
|
||||||
SunxiCedrusDestroyContext(context, (VAContextID) context_object->base.id);
|
SunxiCedrusDestroyContext(context,
|
||||||
context_object = (struct object_context *) object_heap_next(&driver_data->context_heap, &iterator);
|
(VAContextID)context_object->base.id);
|
||||||
|
context_object = (struct object_context *)
|
||||||
|
object_heap_next(&driver_data->context_heap, &iterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
object_heap_destroy(&driver_data->context_heap);
|
object_heap_destroy(&driver_data->context_heap);
|
||||||
|
|
||||||
config_object = (struct object_config *) object_heap_first(&driver_data->config_heap, &iterator);
|
config_object = (struct object_config *)
|
||||||
|
object_heap_first(&driver_data->config_heap, &iterator);
|
||||||
while (config_object != NULL) {
|
while (config_object != NULL) {
|
||||||
SunxiCedrusDestroyConfig(context, (VAConfigID) config_object->base.id);
|
SunxiCedrusDestroyConfig(context,
|
||||||
config_object = (struct object_config *) object_heap_next(&driver_data->config_heap, &iterator);
|
(VAConfigID)config_object->base.id);
|
||||||
|
config_object = (struct object_config *)
|
||||||
|
object_heap_next(&driver_data->config_heap, &iterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
object_heap_destroy(&driver_data->config_heap);
|
object_heap_destroy(&driver_data->config_heap);
|
||||||
|
|||||||
+2
-2
@@ -28,9 +28,9 @@
|
|||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include <va/va.h>
|
|
||||||
#include "object_heap.h"
|
|
||||||
#include "context.h"
|
#include "context.h"
|
||||||
|
#include "object_heap.h"
|
||||||
|
#include <va/va.h>
|
||||||
|
|
||||||
#include <linux/videodev2.h>
|
#include <linux/videodev2.h>
|
||||||
|
|
||||||
|
|||||||
+97
-48
@@ -23,30 +23,31 @@
|
|||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sunxi_cedrus.h"
|
|
||||||
#include "surface.h"
|
#include "surface.h"
|
||||||
|
#include "sunxi_cedrus.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
|
||||||
#include <linux/videodev2.h>
|
#include <linux/videodev2.h>
|
||||||
|
|
||||||
#include "v4l2.h"
|
|
||||||
#include "video.h"
|
|
||||||
#include "media.h"
|
#include "media.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "v4l2.h"
|
||||||
|
#include "video.h"
|
||||||
|
|
||||||
VAStatus SunxiCedrusCreateSurfaces(VADriverContextP context, int width,
|
VAStatus SunxiCedrusCreateSurfaces(VADriverContextP context, int width,
|
||||||
int height, int format, int surfaces_count, VASurfaceID *surfaces_ids)
|
int height, int format, int surfaces_count,
|
||||||
|
VASurfaceID *surfaces_ids)
|
||||||
{
|
{
|
||||||
struct cedrus_data *driver_data =
|
struct cedrus_data *driver_data =
|
||||||
(struct cedrus_data *) context->pDriverData;
|
(struct cedrus_data *)context->pDriverData;
|
||||||
struct object_surface *surface_object;
|
struct object_surface *surface_object;
|
||||||
struct video_format *video_format;
|
struct video_format *video_format;
|
||||||
unsigned int destination_sizes[VIDEO_MAX_PLANES];
|
unsigned int destination_sizes[VIDEO_MAX_PLANES];
|
||||||
@@ -62,7 +63,9 @@ VAStatus SunxiCedrusCreateSurfaces(VADriverContextP context, int width,
|
|||||||
|
|
||||||
driver_data->tiled_format = true;
|
driver_data->tiled_format = true;
|
||||||
|
|
||||||
found = v4l2_find_format(driver_data->video_fd, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, V4L2_PIX_FMT_NV12);
|
found = v4l2_find_format(driver_data->video_fd,
|
||||||
|
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
|
||||||
|
V4L2_PIX_FMT_NV12);
|
||||||
if (found)
|
if (found)
|
||||||
driver_data->tiled_format = false;
|
driver_data->tiled_format = false;
|
||||||
|
|
||||||
@@ -70,15 +73,22 @@ VAStatus SunxiCedrusCreateSurfaces(VADriverContextP context, int width,
|
|||||||
if (video_format == NULL)
|
if (video_format == NULL)
|
||||||
return VA_STATUS_ERROR_OPERATION_FAILED;
|
return VA_STATUS_ERROR_OPERATION_FAILED;
|
||||||
|
|
||||||
rc = v4l2_set_format(driver_data->video_fd, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, video_format->v4l2_format, width, height);
|
rc = v4l2_set_format(driver_data->video_fd,
|
||||||
|
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
|
||||||
|
video_format->v4l2_format, width, height);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
return VA_STATUS_ERROR_OPERATION_FAILED;
|
return VA_STATUS_ERROR_OPERATION_FAILED;
|
||||||
|
|
||||||
rc = v4l2_get_format(driver_data->video_fd, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, NULL, NULL, destination_bytesperlines, destination_sizes, &destination_planes_count);
|
rc = v4l2_get_format(driver_data->video_fd,
|
||||||
|
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, NULL, NULL,
|
||||||
|
destination_bytesperlines, destination_sizes,
|
||||||
|
&destination_planes_count);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
return VA_STATUS_ERROR_OPERATION_FAILED;
|
return VA_STATUS_ERROR_OPERATION_FAILED;
|
||||||
|
|
||||||
rc = v4l2_create_buffers(driver_data->video_fd, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, surfaces_count);
|
rc = v4l2_create_buffers(driver_data->video_fd,
|
||||||
|
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
|
||||||
|
surfaces_count);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
return VA_STATUS_ERROR_ALLOCATION_FAILED;
|
return VA_STATUS_ERROR_ALLOCATION_FAILED;
|
||||||
|
|
||||||
@@ -88,29 +98,47 @@ VAStatus SunxiCedrusCreateSurfaces(VADriverContextP context, int width,
|
|||||||
if (surface_object == NULL)
|
if (surface_object == NULL)
|
||||||
return VA_STATUS_ERROR_ALLOCATION_FAILED;
|
return VA_STATUS_ERROR_ALLOCATION_FAILED;
|
||||||
|
|
||||||
rc = v4l2_request_buffer(driver_data->video_fd, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, i, surface_object->destination_map_lengths, surface_object->destination_map_offsets, video_format->v4l2_buffers_count);
|
rc = v4l2_request_buffer(driver_data->video_fd,
|
||||||
|
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, i,
|
||||||
|
surface_object->destination_map_lengths,
|
||||||
|
surface_object->destination_map_offsets,
|
||||||
|
video_format->v4l2_buffers_count);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
return VA_STATUS_ERROR_ALLOCATION_FAILED;
|
return VA_STATUS_ERROR_ALLOCATION_FAILED;
|
||||||
|
|
||||||
for (j = 0; j < video_format->v4l2_buffers_count; j++) {
|
for (j = 0; j < video_format->v4l2_buffers_count; j++) {
|
||||||
surface_object->destination_map[j] = mmap(NULL, surface_object->destination_map_lengths[j], PROT_READ | PROT_WRITE, MAP_SHARED, driver_data->video_fd, surface_object->destination_map_offsets[j]);
|
surface_object->destination_map[j] =
|
||||||
|
mmap(NULL,
|
||||||
|
surface_object->destination_map_lengths[j],
|
||||||
|
PROT_READ | PROT_WRITE, MAP_SHARED,
|
||||||
|
driver_data->video_fd,
|
||||||
|
surface_object->destination_map_offsets[j]);
|
||||||
|
|
||||||
if (surface_object->destination_map[j] == MAP_FAILED)
|
if (surface_object->destination_map[j] == MAP_FAILED)
|
||||||
return VA_STATUS_ERROR_ALLOCATION_FAILED;
|
return VA_STATUS_ERROR_ALLOCATION_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (video_format->v4l2_buffers_count == 1) {
|
if (video_format->v4l2_buffers_count == 1) {
|
||||||
for (j = 0; j < destination_planes_count; j++) {
|
for (j = 0; j < destination_planes_count; j++) {
|
||||||
surface_object->destination_offsets[j] = j > 0 ? destination_sizes[j-1] : 0;
|
surface_object->destination_offsets[j] =
|
||||||
surface_object->destination_data[j] = (void *) ((unsigned char *) surface_object->destination_map[0] + surface_object->destination_offsets[j]);
|
j > 0 ? destination_sizes[j - 1] : 0;
|
||||||
surface_object->destination_sizes[j] = destination_sizes[j];
|
surface_object->destination_data[j] =
|
||||||
surface_object->destination_bytesperlines[j] = destination_bytesperlines[j];
|
(void *)((unsigned char *)surface_object->destination_map[0] +
|
||||||
|
surface_object->destination_offsets[j]);
|
||||||
|
surface_object->destination_sizes[j] =
|
||||||
|
destination_sizes[j];
|
||||||
|
surface_object->destination_bytesperlines[j] =
|
||||||
|
destination_bytesperlines[j];
|
||||||
}
|
}
|
||||||
} else if (video_format->v4l2_buffers_count == destination_planes_count) {
|
} else if (video_format->v4l2_buffers_count == destination_planes_count) {
|
||||||
for (j = 0; j < destination_planes_count; j++) {
|
for (j = 0; j < destination_planes_count; j++) {
|
||||||
surface_object->destination_offsets[j] = 0;
|
surface_object->destination_offsets[j] = 0;
|
||||||
surface_object->destination_data[j] = surface_object->destination_map[j];
|
surface_object->destination_data[j] =
|
||||||
surface_object->destination_sizes[j] = destination_sizes[j];
|
surface_object->destination_map[j];
|
||||||
surface_object->destination_bytesperlines[j] = destination_bytesperlines[j];
|
surface_object->destination_sizes[j] =
|
||||||
|
destination_sizes[j];
|
||||||
|
surface_object->destination_bytesperlines[j] =
|
||||||
|
destination_bytesperlines[j];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return VA_STATUS_ERROR_ALLOCATION_FAILED;
|
return VA_STATUS_ERROR_ALLOCATION_FAILED;
|
||||||
@@ -126,10 +154,13 @@ VAStatus SunxiCedrusCreateSurfaces(VADriverContextP context, int width,
|
|||||||
|
|
||||||
surface_object->destination_index = 0;
|
surface_object->destination_index = 0;
|
||||||
|
|
||||||
surface_object->destination_planes_count = destination_planes_count;
|
surface_object->destination_planes_count =
|
||||||
surface_object->destination_buffers_count = video_format->v4l2_buffers_count;
|
destination_planes_count;
|
||||||
|
surface_object->destination_buffers_count =
|
||||||
|
video_format->v4l2_buffers_count;
|
||||||
|
|
||||||
memset(&surface_object->params, 0, sizeof(surface_object->params));
|
memset(&surface_object->params, 0,
|
||||||
|
sizeof(surface_object->params));
|
||||||
surface_object->slices_size = 0;
|
surface_object->slices_size = 0;
|
||||||
|
|
||||||
surface_object->request_fd = -1;
|
surface_object->request_fd = -1;
|
||||||
@@ -141,10 +172,11 @@ VAStatus SunxiCedrusCreateSurfaces(VADriverContextP context, int width,
|
|||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusDestroySurfaces(VADriverContextP context,
|
VAStatus SunxiCedrusDestroySurfaces(VADriverContextP context,
|
||||||
VASurfaceID *surfaces_ids, int surfaces_count)
|
VASurfaceID *surfaces_ids,
|
||||||
|
int surfaces_count)
|
||||||
{
|
{
|
||||||
struct cedrus_data *driver_data =
|
struct cedrus_data *driver_data =
|
||||||
(struct cedrus_data *) context->pDriverData;
|
(struct cedrus_data *)context->pDriverData;
|
||||||
struct object_surface *surface_object;
|
struct object_surface *surface_object;
|
||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
|
|
||||||
@@ -153,30 +185,35 @@ VAStatus SunxiCedrusDestroySurfaces(VADriverContextP context,
|
|||||||
if (surface_object == NULL)
|
if (surface_object == NULL)
|
||||||
return VA_STATUS_ERROR_INVALID_SURFACE;
|
return VA_STATUS_ERROR_INVALID_SURFACE;
|
||||||
|
|
||||||
if (surface_object->source_data != NULL && surface_object->source_size > 0)
|
if (surface_object->source_data != NULL &&
|
||||||
munmap(surface_object->source_data, surface_object->source_size);
|
surface_object->source_size > 0)
|
||||||
|
munmap(surface_object->source_data,
|
||||||
|
surface_object->source_size);
|
||||||
|
|
||||||
if (surface_object->request_fd >= 0)
|
if (surface_object->request_fd >= 0)
|
||||||
close(surface_object->request_fd);
|
close(surface_object->request_fd);
|
||||||
|
|
||||||
for (j = 0; j < surface_object->destination_buffers_count; j++)
|
for (j = 0; j < surface_object->destination_buffers_count; j++)
|
||||||
if (surface_object->destination_map[j] != NULL && surface_object->destination_map_lengths[j] > 0)
|
if (surface_object->destination_map[j] != NULL &&
|
||||||
munmap(surface_object->destination_map[j], surface_object->destination_map_lengths[j]);
|
surface_object->destination_map_lengths[j] > 0)
|
||||||
|
munmap(surface_object->destination_map[j],
|
||||||
|
surface_object->destination_map_lengths[j]);
|
||||||
|
|
||||||
if (surface_object->request_fd > 0)
|
if (surface_object->request_fd > 0)
|
||||||
close(surface_object->request_fd);
|
close(surface_object->request_fd);
|
||||||
|
|
||||||
object_heap_free(&driver_data->surface_heap, (struct object_base *) surface_object);
|
object_heap_free(&driver_data->surface_heap,
|
||||||
|
(struct object_base *)surface_object);
|
||||||
}
|
}
|
||||||
|
|
||||||
return VA_STATUS_SUCCESS;
|
return VA_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusSyncSurface(VADriverContextP context,
|
VAStatus SunxiCedrusSyncSurface(VADriverContextP context,
|
||||||
VASurfaceID surface_id)
|
VASurfaceID surface_id)
|
||||||
{
|
{
|
||||||
struct cedrus_data *driver_data =
|
struct cedrus_data *driver_data =
|
||||||
(struct cedrus_data *) context->pDriverData;
|
(struct cedrus_data *)context->pDriverData;
|
||||||
struct object_surface *surface_object;
|
struct object_surface *surface_object;
|
||||||
VAStatus status;
|
VAStatus status;
|
||||||
int request_fd = -1;
|
int request_fd = -1;
|
||||||
@@ -217,13 +254,18 @@ VAStatus SunxiCedrusSyncSurface(VADriverContextP context,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = v4l2_dequeue_buffer(driver_data->video_fd, -1, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, surface_object->source_index, 1);
|
rc = v4l2_dequeue_buffer(driver_data->video_fd, -1,
|
||||||
|
V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
|
||||||
|
surface_object->source_index, 1);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
status = VA_STATUS_ERROR_OPERATION_FAILED;
|
status = VA_STATUS_ERROR_OPERATION_FAILED;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = v4l2_dequeue_buffer(driver_data->video_fd, -1, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, surface_object->destination_index, surface_object->destination_buffers_count);
|
rc = v4l2_dequeue_buffer(driver_data->video_fd, -1,
|
||||||
|
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
|
||||||
|
surface_object->destination_index,
|
||||||
|
surface_object->destination_buffers_count);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
status = VA_STATUS_ERROR_OPERATION_FAILED;
|
status = VA_STATUS_ERROR_OPERATION_FAILED;
|
||||||
goto error;
|
goto error;
|
||||||
@@ -245,10 +287,11 @@ complete:
|
|||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusQuerySurfaceStatus(VADriverContextP context,
|
VAStatus SunxiCedrusQuerySurfaceStatus(VADriverContextP context,
|
||||||
VASurfaceID surface_id, VASurfaceStatus *status)
|
VASurfaceID surface_id,
|
||||||
|
VASurfaceStatus *status)
|
||||||
{
|
{
|
||||||
struct cedrus_data *driver_data =
|
struct cedrus_data *driver_data =
|
||||||
(struct cedrus_data *) context->pDriverData;
|
(struct cedrus_data *)context->pDriverData;
|
||||||
struct object_surface *surface_object;
|
struct object_surface *surface_object;
|
||||||
|
|
||||||
surface_object = SURFACE(driver_data, surface_id);
|
surface_object = SURFACE(driver_data, surface_id);
|
||||||
@@ -261,26 +304,32 @@ VAStatus SunxiCedrusQuerySurfaceStatus(VADriverContextP context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusPutSurface(VADriverContextP context, VASurfaceID surface_id,
|
VAStatus SunxiCedrusPutSurface(VADriverContextP context, VASurfaceID surface_id,
|
||||||
void *draw, short src_x, short src_y, unsigned short src_width,
|
void *draw, short src_x, short src_y,
|
||||||
unsigned short src_height, short dst_x, short dst_y,
|
unsigned short src_width,
|
||||||
unsigned short dst_width, unsigned short dst_height,
|
unsigned short src_height, short dst_x,
|
||||||
VARectangle *cliprects, unsigned int cliprects_count,
|
short dst_y, unsigned short dst_width,
|
||||||
unsigned int flags)
|
unsigned short dst_height,
|
||||||
|
VARectangle *cliprects,
|
||||||
|
unsigned int cliprects_count, unsigned int flags)
|
||||||
{
|
{
|
||||||
return VA_STATUS_ERROR_UNIMPLEMENTED;
|
return VA_STATUS_ERROR_UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusLockSurface(VADriverContextP context,
|
VAStatus SunxiCedrusLockSurface(VADriverContextP context,
|
||||||
VASurfaceID surface_id, unsigned int *fourcc, unsigned int *luma_stride,
|
VASurfaceID surface_id, unsigned int *fourcc,
|
||||||
unsigned int *chroma_u_stride, unsigned int *chroma_v_stride,
|
unsigned int *luma_stride,
|
||||||
unsigned int *luma_offset, unsigned int *chroma_u_offset,
|
unsigned int *chroma_u_stride,
|
||||||
unsigned int *chroma_v_offset, unsigned int *buffer_name, void **buffer)
|
unsigned int *chroma_v_stride,
|
||||||
|
unsigned int *luma_offset,
|
||||||
|
unsigned int *chroma_u_offset,
|
||||||
|
unsigned int *chroma_v_offset,
|
||||||
|
unsigned int *buffer_name, void **buffer)
|
||||||
{
|
{
|
||||||
return VA_STATUS_ERROR_UNIMPLEMENTED;
|
return VA_STATUS_ERROR_UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
VAStatus SunxiCedrusUnlockSurface(VADriverContextP context,
|
VAStatus SunxiCedrusUnlockSurface(VADriverContextP context,
|
||||||
VASurfaceID surface_id)
|
VASurfaceID surface_id)
|
||||||
{
|
{
|
||||||
return VA_STATUS_ERROR_UNIMPLEMENTED;
|
return VA_STATUS_ERROR_UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|||||||
+26
-16
@@ -32,7 +32,8 @@
|
|||||||
|
|
||||||
#include "object_heap.h"
|
#include "object_heap.h"
|
||||||
|
|
||||||
#define SURFACE(data, id) ((struct object_surface *) object_heap_lookup(&(data)->surface_heap, id))
|
#define SURFACE(data, id) \
|
||||||
|
((struct object_surface *)object_heap_lookup(&(data)->surface_heap, id))
|
||||||
#define SURFACE_ID_OFFSET 0x04000000
|
#define SURFACE_ID_OFFSET 0x04000000
|
||||||
|
|
||||||
struct object_surface {
|
struct object_surface {
|
||||||
@@ -74,26 +75,35 @@ struct object_surface {
|
|||||||
};
|
};
|
||||||
|
|
||||||
VAStatus SunxiCedrusCreateSurfaces(VADriverContextP context, int width,
|
VAStatus SunxiCedrusCreateSurfaces(VADriverContextP context, int width,
|
||||||
int height, int format, int surfaces_count, VASurfaceID *surfaces_ids);
|
int height, int format, int surfaces_count,
|
||||||
|
VASurfaceID *surfaces_ids);
|
||||||
VAStatus SunxiCedrusDestroySurfaces(VADriverContextP context,
|
VAStatus SunxiCedrusDestroySurfaces(VADriverContextP context,
|
||||||
VASurfaceID *surfaces_ids, int surfaces_count);
|
VASurfaceID *surfaces_ids,
|
||||||
|
int surfaces_count);
|
||||||
VAStatus SunxiCedrusSyncSurface(VADriverContextP context,
|
VAStatus SunxiCedrusSyncSurface(VADriverContextP context,
|
||||||
VASurfaceID surface_id);
|
VASurfaceID surface_id);
|
||||||
VAStatus SunxiCedrusQuerySurfaceStatus(VADriverContextP context,
|
VAStatus SunxiCedrusQuerySurfaceStatus(VADriverContextP context,
|
||||||
VASurfaceID surface_id, VASurfaceStatus *status);
|
VASurfaceID surface_id,
|
||||||
|
VASurfaceStatus *status);
|
||||||
VAStatus SunxiCedrusPutSurface(VADriverContextP context, VASurfaceID surface_id,
|
VAStatus SunxiCedrusPutSurface(VADriverContextP context, VASurfaceID surface_id,
|
||||||
void *draw, short src_x, short src_y, unsigned short src_width,
|
void *draw, short src_x, short src_y,
|
||||||
unsigned short src_height, short dst_x, short dst_y,
|
unsigned short src_width,
|
||||||
unsigned short dst_width, unsigned short dst_height,
|
unsigned short src_height, short dst_x,
|
||||||
VARectangle *cliprects, unsigned int cliprects_count,
|
short dst_y, unsigned short dst_width,
|
||||||
unsigned int flags);
|
unsigned short dst_height,
|
||||||
|
VARectangle *cliprects,
|
||||||
|
unsigned int cliprects_count,
|
||||||
|
unsigned int flags);
|
||||||
VAStatus SunxiCedrusLockSurface(VADriverContextP context,
|
VAStatus SunxiCedrusLockSurface(VADriverContextP context,
|
||||||
VASurfaceID surface_id, unsigned int *fourcc, unsigned int *luma_stride,
|
VASurfaceID surface_id, unsigned int *fourcc,
|
||||||
unsigned int *chroma_u_stride, unsigned int *chroma_v_stride,
|
unsigned int *luma_stride,
|
||||||
unsigned int *luma_offset, unsigned int *chroma_u_offset,
|
unsigned int *chroma_u_stride,
|
||||||
unsigned int *chroma_v_offset, unsigned int *buffer_name,
|
unsigned int *chroma_v_stride,
|
||||||
void **buffer);
|
unsigned int *luma_offset,
|
||||||
|
unsigned int *chroma_u_offset,
|
||||||
|
unsigned int *chroma_v_offset,
|
||||||
|
unsigned int *buffer_name, void **buffer);
|
||||||
VAStatus SunxiCedrusUnlockSurface(VADriverContextP context,
|
VAStatus SunxiCedrusUnlockSurface(VADriverContextP context,
|
||||||
VASurfaceID surface_id);
|
VASurfaceID surface_id);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+3
-3
@@ -21,10 +21,10 @@
|
|||||||
#define _TILED_YUV_H_
|
#define _TILED_YUV_H_
|
||||||
|
|
||||||
void tiled_to_planar(void *src, void *dst, unsigned int dst_pitch,
|
void tiled_to_planar(void *src, void *dst, unsigned int dst_pitch,
|
||||||
unsigned int width, unsigned int height);
|
unsigned int width, unsigned int height);
|
||||||
|
|
||||||
void tiled_deinterleave_to_planar(void *src, void *dst1, void *dst2,
|
void tiled_deinterleave_to_planar(void *src, void *dst1, void *dst2,
|
||||||
unsigned int dst_pitch,
|
unsigned int dst_pitch, unsigned int width,
|
||||||
unsigned int width, unsigned int height);
|
unsigned int height);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+2
-2
@@ -23,9 +23,9 @@
|
|||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "sunxi_cedrus.h"
|
#include "sunxi_cedrus.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|||||||
+36
-23
@@ -22,15 +22,15 @@
|
|||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
#include <linux/videodev2.h>
|
#include <linux/videodev2.h>
|
||||||
|
|
||||||
#include "v4l2.h"
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "v4l2.h"
|
||||||
|
|
||||||
bool v4l2_find_format(int video_fd, unsigned int type, unsigned int pixelformat)
|
bool v4l2_find_format(int video_fd, unsigned int type, unsigned int pixelformat)
|
||||||
{
|
{
|
||||||
@@ -56,7 +56,7 @@ bool v4l2_find_format(int video_fd, unsigned int type, unsigned int pixelformat)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int v4l2_set_format(int video_fd, unsigned int type, unsigned int pixelformat,
|
int v4l2_set_format(int video_fd, unsigned int type, unsigned int pixelformat,
|
||||||
unsigned int width, unsigned int height)
|
unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
struct v4l2_format format;
|
struct v4l2_format format;
|
||||||
int rc;
|
int rc;
|
||||||
@@ -65,12 +65,14 @@ int v4l2_set_format(int video_fd, unsigned int type, unsigned int pixelformat,
|
|||||||
format.type = type;
|
format.type = type;
|
||||||
format.fmt.pix_mp.width = width;
|
format.fmt.pix_mp.width = width;
|
||||||
format.fmt.pix_mp.height = height;
|
format.fmt.pix_mp.height = height;
|
||||||
format.fmt.pix_mp.plane_fmt[0].sizeimage = type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ? SOURCE_SIZE_MAX : 0;
|
format.fmt.pix_mp.plane_fmt[0].sizeimage =
|
||||||
|
type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ? SOURCE_SIZE_MAX : 0;
|
||||||
format.fmt.pix_mp.pixelformat = pixelformat;
|
format.fmt.pix_mp.pixelformat = pixelformat;
|
||||||
|
|
||||||
rc = ioctl(video_fd, VIDIOC_S_FMT, &format);
|
rc = ioctl(video_fd, VIDIOC_S_FMT, &format);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
sunxi_cedrus_log("Unable to set format for type %d: %s\n", type, strerror(errno));
|
sunxi_cedrus_log("Unable to set format for type %d: %s\n", type,
|
||||||
|
strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,8 +80,8 @@ int v4l2_set_format(int video_fd, unsigned int type, unsigned int pixelformat,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int v4l2_get_format(int video_fd, unsigned int type, unsigned int *width,
|
int v4l2_get_format(int video_fd, unsigned int type, unsigned int *width,
|
||||||
unsigned int *height, unsigned int *bytesperline, unsigned int *sizes,
|
unsigned int *height, unsigned int *bytesperline,
|
||||||
unsigned int *planes_count)
|
unsigned int *sizes, unsigned int *planes_count)
|
||||||
{
|
{
|
||||||
struct v4l2_format format;
|
struct v4l2_format format;
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
@@ -91,7 +93,8 @@ int v4l2_get_format(int video_fd, unsigned int type, unsigned int *width,
|
|||||||
|
|
||||||
rc = ioctl(video_fd, VIDIOC_G_FMT, &format);
|
rc = ioctl(video_fd, VIDIOC_G_FMT, &format);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
sunxi_cedrus_log("Unable to get format for type %d: %s\n", type, strerror(errno));
|
sunxi_cedrus_log("Unable to get format for type %d: %s\n", type,
|
||||||
|
strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +112,8 @@ int v4l2_get_format(int video_fd, unsigned int type, unsigned int *width,
|
|||||||
|
|
||||||
if (bytesperline != NULL)
|
if (bytesperline != NULL)
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
bytesperline[i] = format.fmt.pix_mp.plane_fmt[i].bytesperline;
|
bytesperline[i] =
|
||||||
|
format.fmt.pix_mp.plane_fmt[i].bytesperline;
|
||||||
|
|
||||||
if (sizes != NULL)
|
if (sizes != NULL)
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
@@ -122,7 +126,7 @@ int v4l2_get_format(int video_fd, unsigned int type, unsigned int *width,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int v4l2_create_buffers(int video_fd, unsigned int type,
|
int v4l2_create_buffers(int video_fd, unsigned int type,
|
||||||
unsigned int buffers_count)
|
unsigned int buffers_count)
|
||||||
{
|
{
|
||||||
struct v4l2_create_buffers buffers;
|
struct v4l2_create_buffers buffers;
|
||||||
int rc;
|
int rc;
|
||||||
@@ -134,13 +138,15 @@ int v4l2_create_buffers(int video_fd, unsigned int type,
|
|||||||
|
|
||||||
rc = ioctl(video_fd, VIDIOC_G_FMT, &buffers.format);
|
rc = ioctl(video_fd, VIDIOC_G_FMT, &buffers.format);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
sunxi_cedrus_log("Unable to get format for type %d: %s\n", type, strerror(errno));
|
sunxi_cedrus_log("Unable to get format for type %d: %s\n", type,
|
||||||
|
strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ioctl(video_fd, VIDIOC_CREATE_BUFS, &buffers);
|
rc = ioctl(video_fd, VIDIOC_CREATE_BUFS, &buffers);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
sunxi_cedrus_log("Unable to create buffer for type %d: %s\n", type, strerror(errno));
|
sunxi_cedrus_log("Unable to create buffer for type %d: %s\n",
|
||||||
|
type, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,8 +154,8 @@ int v4l2_create_buffers(int video_fd, unsigned int type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int v4l2_request_buffer(int video_fd, unsigned int type, unsigned int index,
|
int v4l2_request_buffer(int video_fd, unsigned int type, unsigned int index,
|
||||||
unsigned int *lengths, unsigned int *offsets,
|
unsigned int *lengths, unsigned int *offsets,
|
||||||
unsigned int buffers_count)
|
unsigned int buffers_count)
|
||||||
{
|
{
|
||||||
struct v4l2_plane planes[buffers_count];
|
struct v4l2_plane planes[buffers_count];
|
||||||
struct v4l2_buffer buffer;
|
struct v4l2_buffer buffer;
|
||||||
@@ -167,7 +173,8 @@ int v4l2_request_buffer(int video_fd, unsigned int type, unsigned int index,
|
|||||||
|
|
||||||
rc = ioctl(video_fd, VIDIOC_QUERYBUF, &buffer);
|
rc = ioctl(video_fd, VIDIOC_QUERYBUF, &buffer);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
sunxi_cedrus_log("Unable to query buffer: %s\n", strerror(errno));
|
sunxi_cedrus_log("Unable to query buffer: %s\n",
|
||||||
|
strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,7 +190,8 @@ int v4l2_request_buffer(int video_fd, unsigned int type, unsigned int index,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int v4l2_queue_buffer(int video_fd, int request_fd, unsigned int type,
|
int v4l2_queue_buffer(int video_fd, int request_fd, unsigned int type,
|
||||||
unsigned int index, unsigned int size, unsigned int buffers_count)
|
unsigned int index, unsigned int size,
|
||||||
|
unsigned int buffers_count)
|
||||||
{
|
{
|
||||||
struct v4l2_plane planes[buffers_count];
|
struct v4l2_plane planes[buffers_count];
|
||||||
struct v4l2_buffer buffer;
|
struct v4l2_buffer buffer;
|
||||||
@@ -209,7 +217,8 @@ int v4l2_queue_buffer(int video_fd, int request_fd, unsigned int type,
|
|||||||
|
|
||||||
rc = ioctl(video_fd, VIDIOC_QBUF, &buffer);
|
rc = ioctl(video_fd, VIDIOC_QBUF, &buffer);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
sunxi_cedrus_log("Unable to queue buffer: %s\n", strerror(errno));
|
sunxi_cedrus_log("Unable to queue buffer: %s\n",
|
||||||
|
strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,7 +226,7 @@ int v4l2_queue_buffer(int video_fd, int request_fd, unsigned int type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int v4l2_dequeue_buffer(int video_fd, int request_fd, unsigned int type,
|
int v4l2_dequeue_buffer(int video_fd, int request_fd, unsigned int type,
|
||||||
unsigned int index, unsigned int buffers_count)
|
unsigned int index, unsigned int buffers_count)
|
||||||
{
|
{
|
||||||
struct v4l2_plane planes[buffers_count];
|
struct v4l2_plane planes[buffers_count];
|
||||||
struct v4l2_buffer buffer;
|
struct v4l2_buffer buffer;
|
||||||
@@ -239,7 +248,8 @@ int v4l2_dequeue_buffer(int video_fd, int request_fd, unsigned int type,
|
|||||||
|
|
||||||
rc = ioctl(video_fd, VIDIOC_DQBUF, &buffer);
|
rc = ioctl(video_fd, VIDIOC_DQBUF, &buffer);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
sunxi_cedrus_log("Unable to dequeue buffer: %s\n", strerror(errno));
|
sunxi_cedrus_log("Unable to dequeue buffer: %s\n",
|
||||||
|
strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,7 +257,7 @@ int v4l2_dequeue_buffer(int video_fd, int request_fd, unsigned int type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int v4l2_set_control(int video_fd, int request_fd, unsigned int id, void *data,
|
int v4l2_set_control(int video_fd, int request_fd, unsigned int id, void *data,
|
||||||
unsigned int size)
|
unsigned int size)
|
||||||
{
|
{
|
||||||
struct v4l2_ext_control control;
|
struct v4l2_ext_control control;
|
||||||
struct v4l2_ext_controls controls;
|
struct v4l2_ext_controls controls;
|
||||||
@@ -270,7 +280,8 @@ int v4l2_set_control(int video_fd, int request_fd, unsigned int id, void *data,
|
|||||||
|
|
||||||
rc = ioctl(video_fd, VIDIOC_S_EXT_CTRLS, &controls);
|
rc = ioctl(video_fd, VIDIOC_S_EXT_CTRLS, &controls);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
sunxi_cedrus_log("Unable to set control: %s\n", strerror(errno));
|
sunxi_cedrus_log("Unable to set control: %s\n",
|
||||||
|
strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,9 +293,11 @@ int v4l2_set_stream(int video_fd, unsigned int type, bool enable)
|
|||||||
enum v4l2_buf_type buf_type = type;
|
enum v4l2_buf_type buf_type = type;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = ioctl(video_fd, enable ? VIDIOC_STREAMON : VIDIOC_STREAMOFF, &buf_type);
|
rc = ioctl(video_fd, enable ? VIDIOC_STREAMON : VIDIOC_STREAMOFF,
|
||||||
|
&buf_type);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
sunxi_cedrus_log("Unable to %sable stream: %s\n", enable ? "en" : "dis", strerror(errno));
|
sunxi_cedrus_log("Unable to %sable stream: %s\n",
|
||||||
|
enable ? "en" : "dis", strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+11
-10
@@ -30,23 +30,24 @@
|
|||||||
#define SOURCE_SIZE_MAX (1024 * 1024)
|
#define SOURCE_SIZE_MAX (1024 * 1024)
|
||||||
|
|
||||||
bool v4l2_find_format(int video_fd, unsigned int type,
|
bool v4l2_find_format(int video_fd, unsigned int type,
|
||||||
unsigned int pixelformat);
|
unsigned int pixelformat);
|
||||||
int v4l2_set_format(int video_fd, unsigned int type, unsigned int pixelformat,
|
int v4l2_set_format(int video_fd, unsigned int type, unsigned int pixelformat,
|
||||||
unsigned int width, unsigned int height);
|
unsigned int width, unsigned int height);
|
||||||
int v4l2_get_format(int video_fd, unsigned int type, unsigned int *width,
|
int v4l2_get_format(int video_fd, unsigned int type, unsigned int *width,
|
||||||
unsigned int *height, unsigned int *bytesperline, unsigned int *sizes,
|
unsigned int *height, unsigned int *bytesperline,
|
||||||
unsigned int *planes_count);
|
unsigned int *sizes, unsigned int *planes_count);
|
||||||
int v4l2_create_buffers(int video_fd, unsigned int type,
|
int v4l2_create_buffers(int video_fd, unsigned int type,
|
||||||
unsigned int buffers_count);
|
unsigned int buffers_count);
|
||||||
int v4l2_request_buffer(int video_fd, unsigned int type, unsigned int index,
|
int v4l2_request_buffer(int video_fd, unsigned int type, unsigned int index,
|
||||||
unsigned int *lengths, unsigned int *offsets,
|
unsigned int *lengths, unsigned int *offsets,
|
||||||
unsigned int buffers_count);
|
unsigned int buffers_count);
|
||||||
int v4l2_queue_buffer(int video_fd, int request_fd, unsigned int type,
|
int v4l2_queue_buffer(int video_fd, int request_fd, unsigned int type,
|
||||||
unsigned int index, unsigned int size, unsigned int buffers_count);
|
unsigned int index, unsigned int size,
|
||||||
|
unsigned int buffers_count);
|
||||||
int v4l2_dequeue_buffer(int video_fd, int request_fd, unsigned int type,
|
int v4l2_dequeue_buffer(int video_fd, int request_fd, unsigned int type,
|
||||||
unsigned int index, unsigned int buffers_count);
|
unsigned int index, unsigned int buffers_count);
|
||||||
int v4l2_set_control(int video_fd, int request_fd, unsigned int id, void *data,
|
int v4l2_set_control(int video_fd, int request_fd, unsigned int id, void *data,
|
||||||
unsigned int size);
|
unsigned int size);
|
||||||
int v4l2_set_stream(int video_fd, unsigned int type, bool enable);
|
int v4l2_set_stream(int video_fd, unsigned int type, bool enable);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+5
-5
@@ -22,17 +22,17 @@
|
|||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
#include <linux/videodev2.h>
|
|
||||||
#include <drm_fourcc.h>
|
#include <drm_fourcc.h>
|
||||||
|
#include <linux/videodev2.h>
|
||||||
|
|
||||||
#include "video.h"
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "video.h"
|
||||||
|
|
||||||
static inline unsigned int video_v4l2_format(bool tiled_format)
|
static inline unsigned int video_v4l2_format(bool tiled_format)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user