Skip to content

Instantly share code, notes, and snippets.

@rgov
rgov / README.md
Created March 2, 2021 17:30
Use a custom keyring with live-build
apt install dirmngr

In auto/config:

# Create a keyring that contains the keys we need for debootstrap
# See https://github.com/ValveSoftware/steam-runtime/issues/81
gpg "--keyring=$(pwd)/config/keyring.gpg" --no-default-keyring --keyserver keyserver.ubuntu.com --receive-keys 0x40976EAF437D05B5

In auto/build, before the build starts:

@rgov
rgov / NOTES.md
Created February 18, 2021 04:51
Notes on writing an ACPI SSDT
$ i2cdetect -l
i2c-3    unknown    i915 gmbus panel                N/A
i2c-1    unknown    i915 gmbus ssc                  N/A
i2c-8    unknown    DPDDC-C                         N/A
i2c-6    unknown    i915 gmbus dpd                  N/A
i2c-4    unknown    i915 gmbus dpc                  N/A
i2c-2    unknown    i915 gmbus vga                  N/A
i2c-0    unknown    SMBus I801 adapter at e000      N/A
i2c-7    unknown    DPDDC-B                         N/A

i2c-5 unknown i915 gmbus dpb N/A

@rgov
rgov / README.md
Last active February 18, 2021 04:48
Building a custom Ubuntu kernel

I had a need to build a custom Ubuntu 18.04 kernel with a minor config option change.

The build script is based on these instructions from the Ubuntu wiki.

Differences from mainline

  • Enables interrupt support for the PCA9535 GPIO controller
  • Excludes the Nvidia DKMS modules
'''
This module provides a function to enable video capture from screen devices such
as attached iPhones. Only macOS hosts are supported.
enable_screen_capture_devices()
You may need QuickTime running to see the devices:
https://stackoverflow.com/questions/48166748/coremediaio-doesnt-list-iphone-camera-unless-quicktime-is-open
'''
static const char *gpio_alt_names_2711[54*6] =
{
"SDA0" , "SA5" , "PCLK" , "SPI3_CE0_N" , "TXD2" , "SDA6" ,
"SCL0" , "SA4" , "DE" , "SPI3_MISO" , "RXD2" , "SCL6" ,
"SDA1" , "SA3" , "LCD_VSYNC" , "SPI3_MOSI" , "CTS2" , "SDA3" ,
"SCL1" , "SA2" , "LCD_HSYNC" , "SPI3_SCLK" , "RTS2" , "SCL3" ,
"GPCLK0" , "SA1" , "DPI_D0" , "SPI4_CE0_N" , "TXD3" , "SDA3" ,
"GPCLK1" , "SA0" , "DPI_D1" , "SPI4_MISO" , "RXD3" , "SCL3" ,
"GPCLK2" , "SOE_N_SE" , "DPI_D2" , "SPI4_MOSI" , "CTS3" , "SDA4" ,
"SPI0_CE1_N", "SWE_N_SRW_N", "DPI_D3" , "SPI4_SCLK" , "RTS3" , "SCL4" ,
@rgov
rgov / cv-cuda.md
Created August 3, 2020 20:39
Some notes on OpenCV CUDA APIs

Notes from OpenCV 4.4.0.

The CUDA APIs are mostly in the cv2.cuda module except a few that are in cv2 such as cv2.cuda_GpuMat and cv2.cuda_Stream.

cv2.cuda_FarnebackOpticalFlow has the same interface as cv2.FarnebackOpticalFlow.

cv2.cuda.createMorphologyFilter doesn't support 3 channel filters.

You must provide the output array to cv2.cuda.merge(_, output). The API doesn't return a GpuMat instance.

#!/usr/bin/env python3
'''
Attempt to implement a statically type-checked state machine in Python. Doesn't work super well.
'''
import inspect
import typeguard
from typing import Callable, ForwardRef, Optional, Type, Union
@rgov
rgov / llvmsc.py
Created May 17, 2020 18:01
Tool to help with multiple LLVM working trees
#!/usr/bin/env python3
'''
This script helps in maintaining multiple working trees for the LLVM project.
'''
import os
import subprocess
def ensure_main_tree(main):
class MyMemoryview:
def __init__(self, mv):
self._mv = memoryview(mv)
def __getitem__(self, i):
value = self._mv.__getitem__(i)
if isinstance(value, memoryview):
return MyMemoryview(value)
return value
#!/usr/bin/env python3
'''
Compare the rumored device size of a 5.4" iPhone 12 to the beloved first-
generation iPhone SE.
Assumes that the iPhone 12 will have the same screen aspect ratio as the
iPhone 11.
'''
class iPhone: