← Documents Documentation/userspace-api/media/v4l/func-munmap.rst GitHub 원문 ↗

Linux 6.18.37 · Userspace API / Media / V4L

V4L2 munmap()

매핑된 V4L2 buffer를 정확한 주소와 길이로 해제하는 계약을 설명합니다.

Source pathDocumentation/userspace-api/media/v4l/func-munmap.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

func-munmap.rst:1-54

`munmap()`에는 `mmap()`이 반환한 주소와 동일하게 전달했던 plane 길이를 사용해야 하며 값이 틀리거나 매핑이 없으면 EINVAL입니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2 .. c:namespace:: V4L
3
4 .. _func-munmap:
5
6 *************
7 V4L2 munmap()
8 *************
9
10 Name
11 ====
12
13 v4l2-munmap - Unmap device memory
14
15 Synopsis
16 ========
17
18 .. code-block:: c
19
20 #include <unistd.h>
21 #include <sys/mman.h>
22
23 .. c:function:: int munmap( void *start, size_t length )
24
25 Arguments
26 =========
27
28 ``start``
29 Address of the mapped buffer as returned by the
30 :c:func:`mmap()` function.
31
32 ``length``
33 Length of the mapped buffer. This must be the same value as given to
34 :c:func:`mmap()` and returned by the driver in the struct
35 :c:type:`v4l2_buffer` ``length`` field for the
36 single-planar API and in the struct
37 :c:type:`v4l2_plane` ``length`` field for the
38 multi-planar API.
39
40 Description
41 ===========
42
43 Unmaps a previously with the :c:func:`mmap()` function mapped
44 buffer and frees it, if possible.
45
46 Return Value
47 ============
48
49 On success :c:func:`munmap()` returns 0, on failure -1 and the
50 ``errno`` variable is set appropriately:
51
52 EINVAL
53 The ``start`` or ``length`` is incorrect, or no buffers have been
54 mapped yet.
55

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

매핑 해제 선언과 인자

1-39

`v4l2-munmap`은 이전에 매핑한 장치 메모리를 해제합니다. `<unistd.h>`와 `<sys/mman.h>`를 포함하고 `int munmap(void *start, size_t length)`를 호출합니다.

`munmap()` 인자
항목설명
`start``mmap()`이 반환한 mapped buffer 주소입니다.
`length``mmap()`에 전달한 길이와 같아야 합니다. Single-planar는 `v4l2_buffer.length`, multi-planar는 `v4l2_plane.length`입니다.

`mmap()`에서 사용한 pointer와 정확히 같은 길이를 넘깁니다.

.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
.. c:namespace:: V4L

.. _func-munmap:

*************
V4L2 munmap()
*************

Name
====

v4l2-munmap - Unmap device memory

Synopsis
========

.. code-block:: c

    #include <unistd.h>
    #include <sys/mman.h>

.. c:function:: int munmap( void *start, size_t length )

Arguments
=========

``start``
    Address of the mapped buffer as returned by the
    :c:func:`mmap()` function.

``length``
    Length of the mapped buffer. This must be the same value as given to
    :c:func:`mmap()` and returned by the driver in the struct
    :c:type:`v4l2_buffer` ``length`` field for the
    single-planar API and in the struct
    :c:type:`v4l2_plane` ``length`` field for the
    multi-planar API.

해제 동작과 오류

40-54

`munmap()`은 `mmap()`으로 매핑한 buffer를 address space에서 제거하고 가능하면 관련 resource를 해제합니다. 성공하면 0, 실패하면 -1을 반환하고 `errno`를 설정합니다.

`EINVAL`은 `start` 또는 `length`가 올바르지 않거나 아직 매핑한 buffer가 없음을 뜻합니다.

매핑 해제
Mapped buffer 사용 완료원래 `start`와 `length` 확인`munmap(start, length)` 호출0 또는 -1과 `EINVAL` 확인

매핑 때 받은 값을 수정하지 않고 다시 전달합니다.

Description
===========

Unmaps a previously with the :c:func:`mmap()` function mapped
buffer and frees it, if possible.

Return Value
============

On success :c:func:`munmap()` returns 0, on failure -1 and the
``errno`` variable is set appropriately:

EINVAL
    The ``start`` or ``length`` is incorrect, or no buffers have been
    mapped yet.