コード例 #1
0
        private void VerifyEndpointDirection(byte endpointAddress, TransferFlags expectedFlag)
        {
            // Verify direction
            bool isFlagDirIn =
                (expectedFlag & TransferFlags.USBD_TRANSFER_DIRECTION_IN) == TransferFlags.USBD_TRANSFER_DIRECTION_IN;
            bool isEndpointDirIn =
                (endpointAddress >> 7) == 1;

            if (isFlagDirIn != isEndpointDirIn)
            {
                throw new ArgumentException(String.Format(
                                                "flag is not consistent to endpoint direction. flag: {0}, Endpoint: {1}.",
                                                expectedFlag,
                                                isEndpointDirIn ? "In" : "Out"
                                                ));
            }
        }
コード例 #2
0
        /// <summary>
        /// Builds a request to receive data on a bulk pipe, or receive data on an interrupt pipe.
        /// </summary>
        /// <param name="endpoints">All information of the pipes to be searched.</param>
        /// <param name="endpointNumber">The endpoint number.</param>
        /// <param name="flag">The endpoint flag.</param>
        /// <param name="type">The type of the endpoint.</param>
        /// <returns>The request containing the pipe handle found to receive data on a bulk pipe, or receive data on an interrupt pipe.</returns>
        public TS_URB_BULK_OR_INTERRUPT_TRANSFER BuildInterruptTransferRequest(TS_USBD_PIPE_INFORMATION_RESULT[] endpoints, byte endpointNumber, TransferFlags flag, USBD_PIPE_TYPE type)
        {
            if (((flag & TransferFlags.USBD_TRANSFER_DIRECTION_IN) != TransferFlags.USBD_TRANSFER_DIRECTION_IN) &&
                ((flag & TransferFlags.USBD_TRANSFER_DIRECTION_OUT) != TransferFlags.USBD_TRANSFER_DIRECTION_OUT))
            {
                throw new ArgumentException("flag must contain the direction flag.");
            }

            TS_URB_BULK_OR_INTERRUPT_TRANSFER req = new TS_URB_BULK_OR_INTERRUPT_TRANSFER(
                this.requestId,
                this.noAck
                );

            req.Header.URB_Function = this.function;

            req.Header.Size   = 8 + 4 + 4;
            req.TransferFlags = (uint)flag;

            bool found = false;

            // Looking for the correct pipe handle.
            foreach (TS_USBD_PIPE_INFORMATION_RESULT e in endpoints)
            {
                byte num = (byte)(e.EndpointAddress & 0x0F);
                if (num == endpointNumber)
                {
                    VerifyEndpointDirection(e.EndpointAddress, flag);

                    VerifyType(e.PipeType, type);

                    req.PipeHandle = e.PipeHandle;
                    found          = true;
                    break;
                }
            }

            if (!found)
            {
                throw new ArgumentException(String.Format("Specified endpoint ({0}) cannot be found.", endpointNumber));
            }

            return(req);
        }
コード例 #3
0
 internal static extern nint gbm_bo_map(gbm_bo *bo, uint x, uint y, uint width, uint height, TransferFlags flags, ref uint stride, out nint data);
コード例 #4
0
        /// <summary>
        /// Builds a vendor command request.
        /// </summary>
        /// <param name="request">Specifies the USB or vendor-defined request code for the device, interface, endpoint, or other device-defined target. </param>
        /// <param name="value">Specifies a value, specific to Request, that becomes part of the USB-defined setup packet for the target. This value is defined by the creator of the code used in Request.</param>
        /// <param name="flag">Specifies zero, one, or a combination of the flags of type TransferFlags.</param>
        /// <returns>The vendor command request.</returns>
        public TS_URB_CONTROL_VENDOR_OR_CLASS_REQUEST BuildVendorCommandRequest(byte request, ushort value, TransferFlags flag)
        {
            TS_URB_CONTROL_VENDOR_OR_CLASS_REQUEST req = new TS_URB_CONTROL_VENDOR_OR_CLASS_REQUEST(
                this.requestId,
                this.noAck,
                URB_FUNCTIONID.URB_FUNCTION_VENDOR_DEVICE
                );

            req.Header.Size             = 8 + 4 + 1 + 1 + 2 + 2 + 2;
            req.TransferFlags           = (uint)flag;
            req.RequestTypeReservedBits = 0;
            req.Request = request;
            req.Value   = value;
            req.Index   = 0;
            req.Padding = 0;// PaddingGenerator.GeneratePadding();

            return(req);
        }
コード例 #5
0
 internal static extern IntPtr gbm_bo_map(ref gbm_bo bo, uint x, uint y, uint width, uint height, TransferFlags flags, ref uint stride, out IntPtr data);